結果
問題 | No.502 階乗を計算するだけ |
ユーザー |
![]() |
提出日時 | 2017-06-30 11:01:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 76 ms / 1,000 ms |
コード長 | 916 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 20:33:54 |
合計ジャッジ時間 | 1,870 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#include<cstdio> using ll=long long; #define MOD 1000000007 int table[]={ 1,800304985,361946029,944323045,117175975,212131504,532814826,698398808,638916270,166114276,709912685, 309672260,565479858,952004841,534784668,667220314,864357307,104909388,580002085,624854174,988122582, 104372309,626052914,62200437,711403642,516388569,930569788,117111267,928062158,619843354,782871805, 531967768,373979365,38760888,75908005,339599190,861919911,410124462,973727253,391452566,963971145, 587953096,892153437,767810085,976333508,330000241,204474745,279527279,183143523,994918408,224645330, 809913797,885152995,118809938,514060757,58160791,894672548,767161925,683957845,373529632, }; int main(void) { ll n; while(scanf("%lld", &n)==1) { if(n>=MOD) { printf("0\n"); continue; } ll r=table[n>>24]; for(ll i=((n>>24)<<24)+1;i<=n;i++) { r=(r*(i%MOD))%MOD; } printf("%lld\n", r); } return 0; }