結果
問題 | No.500 階乗電卓 |
ユーザー |
|
提出日時 | 2017-04-07 22:28:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 895 bytes |
コンパイル時間 | 957 ms |
コンパイル使用メモリ | 103,044 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 02:47:53 |
合計ジャッジ時間 | 1,757 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#define _USE_MATH_DEFINES#include <cstdio>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <algorithm>#include <cmath>#include <complex>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <set>#include <map>#include <bitset>#include <numeric>#include <limits>#include <climits>#include <cfloat>#include <functional>#include <iterator>using namespace std;const long long MOD = 1000000000000;int main(){long long n;cin >> n;long long x = 1;bool isLarge = false;for(long long i=1; i<=n; ++i){x *= i;if(x >= MOD){isLarge = true;x %= MOD;if(x == 0)break;}}string s = to_string(x);if(isLarge)s = string(12 - s.size(), '0') + s;cout << s << endl;return 0;}