結果
問題 | No.500 階乗電卓 |
ユーザー |
👑 |
提出日時 | 2019-10-31 21:49:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 552 bytes |
コンパイル時間 | 640 ms |
コンパイル使用メモリ | 65,024 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 22:12:09 |
合計ジャッジ時間 | 1,460 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream> using namespace std; int main(){ long long n;cin>>n; if(n >= 50){ cout << "000000000000" << endl; return 0; } long long ans = 1; bool ok = false; for(long long i = 1; n >= i; i++){ ans = (ans*i); if(ans/1000000000000){ ok = true; ans %= 1000000000000; } } if(ok){ string s = to_string(ans); for(int i = 0; 12-s.size() > i; i++){ cout << '0'; } cout << s << endl; }else{ cout << ans << endl; } }