結果
問題 |
No.500 階乗電卓
|
ユーザー |
![]() |
提出日時 | 2025-06-19 19:31:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 602 bytes |
コンパイル時間 | 1,432 ms |
コンパイル使用メモリ | 164,008 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-19 19:31:45 |
合計ジャッジ時間 | 2,585 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:3:25: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 3 | # define FILE(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~ main.cpp:10:5: note: in expansion of macro ‘FILE’ 10 | FILE("factorial"); | ^~~~ main.cpp:3:54: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 3 | # define FILE(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:10:5: note: in expansion of macro ‘FILE’ 10 | FILE("factorial"); | ^~~~
ソースコード
# include <bits/stdc++.h> # define int long long # define FILE(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout); using namespace std; const int mod = 1e12; int n; int ans = 1; signed main() { FILE("factorial"); cin >> n; if (n >= 50) { for (int i = 1; i <= 12; i ++) { cout << 0; } return 0; } for (int i = 1; i <= n; i ++) { ans = ans * i % mod; } string s = to_string(ans); while (s.size() < 12) { s = "0" + s; } if (n >= 15) cout << s; else cout << ans; return 0; }