結果
| 問題 |
No.502 階乗を計算するだけ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-08 01:09:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 722 ms |
| コンパイル使用メモリ | 69,260 KB |
| 実行使用メモリ | 13,760 KB |
| 最終ジャッジ日時 | 2024-07-16 03:36:27 |
| 合計ジャッジ時間 | 3,443 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 TLE * 1 -- * 19 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
long long mod = 1e9 + 7;
long long sub = 1e8;
long long fact[11] = {
1,
927880474,
933245637,
668123525,
429277690,
733333339,
724464507,
957939114,
203191898,
586445753,
698611116
};
void calc_mod_fact() {
long long x = 1;
cout << x << endl;
for (int i = 1; i <= sub * 10; i++) {
x = x * i % mod;
if (i % sub == 0) {
cout << x << endl;
}
}
}
int main() {
// calc_mod_fact();
long long n;
cin >> n;
if (n >= mod) {
cout << 0 << endl;
return 0;
}
int idx = n / sub;
long long x = fact[idx];
for (int i = 10 * idx + 1; i <= n; i++) {
x = x * i % mod;
}
cout << x << endl;
return 0;
}