結果
問題 | No.500 階乗電卓 |
ユーザー |
|
提出日時 | 2017-04-07 22:38:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 396 bytes |
コンパイル時間 | 600 ms |
コンパイル使用メモリ | 70,928 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 02:49:26 |
合計ジャッジ時間 | 1,371 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream>#include<iomanip>using namespace std;long n,c5;main(){cin>>n;long i=1;while(n>i)c5+=n/(i*=5);if(c5>=12)cout<<"000000000000"<<endl;else{long M=1e12;long ans=1;bool flag=false;for(i=2;i<=n;i++){ans*=i;if(ans>=M){flag=true;ans%=M;}}if(flag)cout<<setfill('0')<<setw(12)<<right<<ans<<endl;else cout<<ans<<endl;}}