結果
| 問題 |
No.1281 Cigarette Distribution
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-06 22:07:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 257 ms / 2,000 ms |
| コード長 | 1,264 bytes |
| コンパイル時間 | 676 ms |
| コンパイル使用メモリ | 92,884 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 12:54:05 |
| 合計ジャッジ時間 | 3,511 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#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;
}
}
}