結果
問題 | No.1281 Cigarette Distribution |
ユーザー |
![]() |
提出日時 | 2020-05-17 18:45:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 272 ms / 2,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 66,944 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 03:12:15 |
合計ジャッジ時間 | 3,868 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <iostream> #include <algorithm> #include <cassert> #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; typedef long long LL; const int Max_Num=2e5; const LL mod=1e9+7; LL modpow(LL x, LL n){ LL r=1; while(n){ if(n&1) r=r*x%mod; x=x*x%mod; n>>=1; } return r; } int main(){ int N, M; cin >> N >> M; assert(N>=1 && N<=Max_Num); assert(M>=1 && M<=N); for(LL X=1; X<=M; X++){ LL dis=(N+1)/X; LL rem=(N+1)%X; LL ans=modpow(dis,X-rem-1)*modpow(dis+1,rem)%mod; ans*=dis-1, ans%=mod; cout << ans << endl; } return 0; }