結果
問題 | No.500 階乗電卓 |
ユーザー |
![]() |
提出日時 | 2019-07-18 23:14:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 501 bytes |
コンパイル時間 | 645 ms |
コンパイル使用メモリ | 74,776 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 22:43:14 |
合計ジャッジ時間 | 1,595 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) { cout << setfill('0') << setw(12) << fact << endl; } else { cout << fact << endl; } return 0; }