結果
問題 |
No.500 階乗電卓
|
ユーザー |
![]() |
提出日時 | 2019-07-18 23:19:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 637 ms |
コンパイル使用メモリ | 74,140 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 22:43:16 |
合計ジャッジ時間 | 1,409 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> #include <iomanip> using namespace std; using ll = long long; const ll MOD = 1e12; int main() { int n; cin >> n; ll fact = 1; bool is_overflowed = false; for (int i = 1; fact && i <= n; i++) { if (fact * i >= MOD) is_overflowed = true; (fact *= i) %= MOD; } if (is_overflowed) { printf("%012lld\n", fact); } else { cout << fact << endl; } return 0; }