結果
問題 | No.502 階乗を計算するだけ |
ユーザー |
|
提出日時 | 2017-04-07 23:22:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 526 ms / 1,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 849 ms |
コンパイル使用メモリ | 103,068 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 03:04:11 |
合計ジャッジ時間 | 5,366 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#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 int MOD = 1000000007; const vector<pair<int, int> > tmp = { { 0, 1 }, { 10000000, 682498929 }, { 200000000, 933245637 }, { 300000000, 668123525 }, { 400000000, 429277690 }, { 500000000, 733333339 }, { 600000000, 724464507 }, { 700000000, 957939114 }, { 800000000, 203191898 }, { 900000000, 586445753 }, { 1000000000, 698611116 }, { 1100000000, 0 }, }; int main() { long long n; cin >> n; if(n >= MOD){ cout << 0 << endl; return 0; } int k = 0; while(tmp[k+1].first < n) ++ k; long long x = tmp[k].second; for(long long i=tmp[k].first+1; i<=n; ++i){ x *= i; x %= MOD; } cout << x << endl; return 0; }