結果

問題 No.1281 Cigarette Distribution
ユーザー 夜
提出日時 2020-11-06 22:07:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 90,972 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 18:49:57
合計ジャッジ時間 4,017 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 78 ms
4,380 KB
testcase_13 AC 181 ms
4,376 KB
testcase_14 AC 134 ms
4,376 KB
testcase_15 AC 91 ms
4,376 KB
testcase_16 AC 114 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 282 ms
4,380 KB
testcase_19 AC 285 ms
4,376 KB
testcase_20 AC 279 ms
4,380 KB
testcase_21 AC 157 ms
4,380 KB
testcase_22 AC 184 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		long long x, y, ans;
		long long n1 = n;
		if (n <= i * 2 - 2) {
			cout << "0" << endl;
		}
		else {
			long long ans3 = 1;
			n1 -= i * 2 - 1;
			x = 2 + n1 / i;
			y = i - n1 % i;
			ans = 1;
			while (y > 0) {
				if ((y & 1) == 1) {
					ans = ans * x % 1000000007;
				}
				x = x * x % 1000000007;
				y >>= 1;
			}
			x = 2 + n1 / i + 1;
			y = n1 % i;
			long long ans1 = 1;
			while (y > 0) {
				if ((y & 1) == 1) {
					ans1 = ans1 * x % 1000000007;
				}
				x = x * x % 1000000007;
				y >>= 1;
			}
			x= 2 + n1 / i;
			y = i - n1 % i - 1;
			long long ans2 = 1;
			while (y > 0) {
				if ((y & 1) == 1) {
					ans2 = ans2 * x % 1000000007;
				}
				x = x * x % 1000000007;
				y >>= 1;
			}
			ans3 = (ans * ans1) % 1000000007;
			ans3 = ans3 - ((ans1 * ans2) % 1000000007);
			ans3 %= 1000000007;
			if (ans3 < 0) {
				ans3 += 1000000007;
			}
			cout << ans3 << endl;
		}
	}
}
0