結果
問題 |
No.500 階乗電卓
|
ユーザー |
|
提出日時 | 2020-11-05 15:52:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 1,614 ms |
コンパイル使用メモリ | 167,888 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 11:12:37 |
合計ジャッジ時間 | 2,438 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 18 WA * 2 |
ソースコード
#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) { for (int i = max(0, 11 - (int)s.size()); i > -1; i--) { s = "0" + s; } } cout << s << endl; return 0; } }