結果
| 問題 |
No.500 階乗電卓
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-07 22:29:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 454 bytes |
| コンパイル時間 | 537 ms |
| コンパイル使用メモリ | 68,572 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 02:48:19 |
| 合計ジャッジ時間 | 1,291 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
long long mod = 1e12;
int main() {
int n;
cin >> n;
bool hasZero = false;
long long x = 1;
if (n >= 100) {
hasZero = true;
x = 0;
} else {
for (int i = 1; i <= n; i++) {
x = x * i;
if (x >= mod) {
hasZero = true;
}
x %= mod;
}
}
if (hasZero) {
printf("%012lld\n", x);
} else {
printf("%lld\n", x);
}
return 0;
}