結果
問題 | No.1281 Cigarette Distribution |
ユーザー | 👑 kmjp |
提出日時 | 2020-11-06 22:30:55 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 1,475 bytes |
コンパイル時間 | 2,114 ms |
コンパイル使用メモリ | 200,220 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-29 19:11:07 |
合計ジャッジ時間 | 5,296 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,384 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 75 ms
4,380 KB |
testcase_13 | AC | 170 ms
4,380 KB |
testcase_14 | AC | 128 ms
4,380 KB |
testcase_15 | AC | 86 ms
4,376 KB |
testcase_16 | AC | 109 ms
4,380 KB |
testcase_17 | AC | 3 ms
4,376 KB |
testcase_18 | AC | 274 ms
4,380 KB |
testcase_19 | AC | 269 ms
4,380 KB |
testcase_20 | AC | 272 ms
4,376 KB |
testcase_21 | AC | 148 ms
4,376 KB |
testcase_22 | AC | 179 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M; const ll mo=1000000007; ll modpow(ll a, ll n = mo-2) { ll r=1;a%=mo; while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1; return r; } ll hoge(int N,int M) { int i,x; if(M==1) return N; if(N<=2*(M-1)) return 0; int N2=((N+2)+M-1)/M-2; int low=N2+(N2+1)*(M-1); int add=N-low; ll ret=N2; ret=ret*modpow(N2+1,M-1-add)%mo; ret=ret*modpow(N2+2,add)%mo; /* cout<<N2; FOR(i,M-1-add) cout<<N2+1; FOR(i,add) cout<<N2+2; cout<<endl; vector<int> V(M); FOR(i,N) { V[0]++; sort(ALL(V)); V[0]++; sort(ALL(V)); FOR(x,M) if(V[x]) { V[x]--; break; } sort(ALL(V)); } FORR(v,V) cout<<v; cout<<endl; */ return ret; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M; for(i=1;i<=M;i++) cout<<hoge(N,i)<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }