結果
| 問題 |
No.1281 Cigarette Distribution
|
| コンテスト | |
| ユーザー |
oevl
|
| 提出日時 | 2020-11-07 01:25:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 651 bytes |
| コンパイル時間 | 1,940 ms |
| コンパイル使用メモリ | 192,108 KB |
| 最終ジャッジ日時 | 2025-01-15 21:22:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powMod(long long x, long long n, long long mod) {
long long res = 1LL;
while(n > 0) {
if(n & 1) res = res * x % mod;
x = x * x % mod;
n = n >> 1;
}
return res;
}
long long solve(int n, int m, int x) {
if(n < 2 * x - 1) return 0;
int v = (n + x - 1) / x;
int a = n % x;
if(!a) a = x;
long long ans = powMod(v, a, mod) * powMod(v - 1, x - a, mod) % mod;
return ans;
}
int main() {
int n, m;
cin >> n >> m;
for(int x = 1; x <= m; ++x) {
cout << solve(n, m, x) << '\n';
}
}
oevl