結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-16 22:47:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 579 bytes |
| 記録 | |
| コンパイル時間 | 642 ms |
| コンパイル使用メモリ | 73,312 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 13:21:44 |
| 合計ジャッジ時間 | 1,322 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
#define MOD 1000000000000
int main(){
ll n;
cin >> n;
if(n >= 50) cout << "000000000000" << endl;
else{
ll ans = 1;
bool overflow = false;
for(ll i = n; i >= 2; i--){
ans *= i;
if(ans > MOD){
ans %= MOD;
overflow = true;
}
}
if(overflow) cout << setw(12) << setfill('0') << ans << endl;
else cout << ans << endl;
}
return 0;
}