結果

問題 No.502 階乗を計算するだけ
ユーザー koba-e964koba-e964
提出日時 2017-04-07 23:41:20
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 103 ms / 1,000 ms
コード長 1,702 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 87,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 03:17:41
合計ジャッジ時間 2,370 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
ll tbl[] = {
1,
491101308,
723816384,
27368307,
199888908,
927880474,
661224977,
970055531,
195888993,
547665832,
933245637,
368925948,
136026497,
135498044,
419363534,
668123525,
30977140,
309058615,
189239124,
940567523,
429277690,
358655417,
780072518,
275105629,
99199382,
733333339,
608823837,
141827977,
637939935,
848924691,
724464507,
326159309,
903466878,
769795511,
606241871,
957939114,
852304035,
375297772,
624148346,
624500515,
203191898,
629786193,
814362881,
116667533,
627655552,
586445753,
193781724,
83868974,
965785236,
377329025,
698611116,
};
void precompute() {
ll prod = 1;
REP(i, 1, mod) {
prod = prod * i % mod;
if (i % 20000000 == 0) {
cout << prod << "," << endl;
}
}
}
int main(void){
ll n;
cin >> n;
if (n >= mod) {
cout << 0 << endl;
return 0;
}
const int B = 20000000;
int t = n / B;
ll prod = tbl[t];
for (int i = t * B + 1; i <= n; ++i) {
prod = prod * i % mod;
}
cout << prod << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0