結果
問題 | No.502 階乗を計算するだけ |
ユーザー | kenta255 |
提出日時 | 2019-07-25 00:39:00 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 57 ms / 1,000 ms |
コード長 | 3,257 bytes |
コンパイル時間 | 2,190 ms |
コンパイル使用メモリ | 201,472 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 14:50:22 |
合計ジャッジ時間 | 3,874 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 7 ms
5,376 KB |
testcase_23 | AC | 3 ms
5,376 KB |
testcase_24 | AC | 5 ms
5,376 KB |
testcase_25 | AC | 3 ms
5,376 KB |
testcase_26 | AC | 4 ms
5,376 KB |
testcase_27 | AC | 3 ms
5,376 KB |
testcase_28 | AC | 3 ms
5,376 KB |
testcase_29 | AC | 3 ms
5,376 KB |
testcase_30 | AC | 7 ms
5,376 KB |
testcase_31 | AC | 4 ms
5,376 KB |
testcase_32 | AC | 35 ms
5,376 KB |
testcase_33 | AC | 57 ms
5,376 KB |
testcase_34 | AC | 53 ms
5,376 KB |
testcase_35 | AC | 56 ms
5,376 KB |
testcase_36 | AC | 30 ms
5,376 KB |
testcase_37 | AC | 56 ms
5,376 KB |
testcase_38 | AC | 25 ms
5,376 KB |
testcase_39 | AC | 50 ms
5,376 KB |
testcase_40 | AC | 11 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll,ll> #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v x is sorted #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v x is sorted #define NUM(x,v) (POSU(x,v)-POSL(x,v)) //x is sorted #define REV(x) (reverse(x.begin(),x.end())) //reverse ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);} ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu #define NEXTP(x) next_permutation(x.begin(),x.end()) const ll INF=1e18+7; const ll MOD=1e9+7; #define out(a) cout<<fixed<<setprecision((a)) int main(){ ll n; cin >> n; if(n>=MOD){ cout << 0 << endl; return 0; } ll ans[101] = {}; ans[0] = 1; ans[1] = 682498929; ans[2] = 491101308; ans[3] = 76479948; ans[4] = 723816384; ans[5] = 67347853; ans[6] = 27368307; ans[7] = 625544428; ans[8] = 199888908; ans[9] = 888050723; ans[10] = 927880474; ans[11] = 281863274; ans[12] = 661224977; ans[13] = 623534362; ans[14] = 970055531; ans[15] = 261384175; ans[16] = 195888993; ans[17] = 66404266; ans[18] = 547665832; ans[19] = 109838563; ans[20] = 933245637; ans[21] = 724691727; ans[22] = 368925948; ans[23] = 268838846; ans[24] = 136026497; ans[25] = 112390913; ans[26] = 135498044; ans[27] = 217544623; ans[28] = 419363534; ans[29] = 500780548; ans[30] = 668123525; ans[31] = 128487469; ans[32] = 30977140; ans[33] = 522049725; ans[34] = 309058615; ans[35] = 386027524; ans[36] = 189239124; ans[37] = 148528617; ans[38] = 940567523; ans[39] = 917084264; ans[40] = 429277690; ans[41] = 996164327; ans[42] = 358655417; ans[43] = 568392357; ans[44] = 780072518; ans[45] = 462639908; ans[46] = 275105629; ans[47] = 909210595; ans[48] = 99199382; ans[49] = 703397904; ans[50] = 733333339; ans[51] = 97830135; ans[52] = 608823837; ans[53] = 256141983; ans[54] = 141827977; ans[55] = 696628828; ans[56] = 637939935; ans[57] = 811575797; ans[58] = 848924691; ans[59] = 131772368; ans[60] = 724464507; ans[61] = 272814771; ans[62] = 326159309; ans[63] = 456152084; ans[64] = 903466878; ans[65] = 92255682; ans[66] = 769795511; ans[67] = 373745190; ans[68] = 606241871; ans[69] = 825871994; ans[70] = 957939114; ans[71] = 435887178; ans[72] = 852304035; ans[73] = 663307737; ans[74] = 375297772; ans[75] = 217598709; ans[76] = 624148346; ans[77] = 671734977; ans[78] = 624500515; ans[79] = 748510389; ans[80] = 203191898; ans[81] = 423951674; ans[82] = 629786193; ans[83] = 672850561; ans[84] = 814362881; ans[85] = 823845496; ans[86] = 116667533; ans[87] = 256473217; ans[88] = 627655552; ans[89] = 245795606; ans[90] = 586445753; ans[91] = 172114298; ans[92] = 193781724; ans[93] = 778983779; ans[94] = 83868974; ans[95] = 315103615; ans[96] = 965785236; ans[97] = 492741665; ans[98] = 377329025; ans[99] = 847549272; ans[100] = 698611116; ll k = n/10000000; ll a = ans[ k ]; FOR(i,k*10000000+1,n+1){ (a*=i)%=MOD; } cout << a << endl; }