結果
問題 | No.500 階乗電卓 |
ユーザー |
![]() |
提出日時 | 2017-10-14 00:43:52 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 471 ms |
コンパイル使用メモリ | 61,816 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:05:01 |
合計ジャッジ時間 | 1,250 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream>#include <string>#include <iomanip>using namespace std;int main() {const long long max = 1e12;long long answer = 1, temp = 1;long long n;cin >> n;n = n > 10002 ? 10001 : n;for (long long i = 2; i <= n; i++) {answer *= i;if (temp < max) {temp *= i;}answer %= max;}if (temp >= max) {cout << std::setfill('0') << std::right << std::setw(12) << answer << "\n";}else {cout << answer << "\n";}int a;cin >> a;return 0;}