結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2019-02-27 23:37:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,035 bytes |
| 記録 | |
| コンパイル時間 | 1,325 ms |
| コンパイル使用メモリ | 159,204 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 05:23:12 |
| 合計ジャッジ時間 | 2,103 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e12;
int main() {
// 1. 入力情報取得.
LL N;
cin >> N;
// 2. N! を 10 の 12乗 で割った余りは?
// 階乗計算 早見表.
// https://www.nap.st/factorial_calculation/?lang=ja
// 50! = 30414093201713378043612608166064768844377641568960512000000000000
// -> 上記サイトから, 50! で, はじめて下12桁が, 000000000000 となる.
// なので, N が 50以上 であれば, 000000000000 が解答のはず.
// 2-1. N >= 50 の 場合.
if(N >= 50){
cout << "000000000000" << endl;
return 0;
}
// 2-2. N < 50 の 場合.
LL ans = 1;
// for(int i = 1; i <= N; i++) ans *= i, ans %= MOD;
// for(LL i = 1; i <= N; i++) ans *= i, ans %= MOD;
// -> test7.txt, test8.txt で, WAとなったので, いったん修正.
for(LL i = N; i > 1; i--) ans *= i, ans %= MOD;
cout << ans << endl;
// 3. 後処理.
return 0;
}
@abcde