結果
| 問題 |
No.502 階乗を計算するだけ
|
| ユーザー |
cosnomi
|
| 提出日時 | 2019-11-16 22:52:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 707 bytes |
| コンパイル時間 | 707 ms |
| コンパイル使用メモリ | 77,996 KB |
| 実行使用メモリ | 10,272 KB |
| 最終ジャッジ日時 | 2024-09-25 05:44:16 |
| 合計ジャッジ時間 | 3,823 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 TLE * 1 -- * 19 |
ソースコード
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;
int M = 1000000007;
long mod_mul(long a, long b)
{
return ((a % M) * (b % M)) % M;
}
long mod_factorial(int n)
{
long res = 1;
for (int i = 1; i <= n; i++)
{
res = mod_mul(res, i);
}
// cout << "fact:" << n << " " << res << endl;
return res;
}
long mod_pow(int n, int m)
{
if (m == 0)
return 1;
else if (m == 1)
return n % M;
else if (m % 2 == 0)
{
return (long)pow(mod_pow(n, m / 2), 2) % M;
}
return (long)mod_mul((mod_pow(n, m - 1)), n);
}
int main() {
int n;
cin >> n;
cout << mod_factorial(n) << endl;
}
cosnomi