結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-05 15:55:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 931 bytes |
| コンパイル時間 | 1,588 ms |
| コンパイル使用メモリ | 167,792 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 11:12:48 |
| 合計ジャッジ時間 | 2,351 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
ll MOD = pow(10, 12);
ll sum = 1, exp = 1;
if (N >= 65) {
cout << "000000000000" << endl;
return 0;
} else {
ll sum = 1;
for (int i = N; i > 0; i--) {
sum *= i;
sum %= MOD;
if (sum == 0) {
cout << "000000000000" << endl;
return 0;
}
}
string s = to_string(sum);
if (N >= 16) {
int cnt = max(0, 12 - (int)s.size());
rep(i, cnt) { s = '0' + s; }
}
cout << s << endl;
return 0;
}
}