結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-04-18 23:15:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 437 bytes |
| 記録 | |
| コンパイル時間 | 2,174 ms |
| コンパイル使用メモリ | 191,200 KB |
| 最終ジャッジ日時 | 2025-01-09 21:20:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 14 WA * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
19 | printf("%012d\n", ans);
| ~~~~^ ~~~
| | |
| int int64_t {aka long int}
| %012ld
main.cpp:21:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
21 | printf("%d\n", ans);
| ~^ ~~~
| | |
| int int64_t {aka long int}
| %ld
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n;
cin >> n;
if (n >= 50) {
puts("000000000000");
return 0;
}
bool big = false;
int64_t ans = 1;
for (int i = 1; i <= n; i++) {
ans *= i;
if (ans >= 1000000000000) big = true;
ans %= 1000000000000;
}
if (big) {
printf("%012d\n", ans);
} else {
printf("%d\n", ans);
}
}
trineutron