結果

問題 No.502 階乗を計算するだけ
ユーザー 👑 NachiaNachia
提出日時 2020-12-29 17:41:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 1,000 ms
コード長 608 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 195,328 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 17:54:47
合計ジャッジ時間 5,373 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 6 ms
6,944 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 4 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 3 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 6 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 143 ms
6,944 KB
testcase_33 AC 124 ms
6,940 KB
testcase_34 AC 146 ms
6,944 KB
testcase_35 AC 126 ms
6,940 KB
testcase_36 AC 120 ms
6,940 KB
testcase_37 AC 43 ms
6,940 KB
testcase_38 AC 112 ms
6,940 KB
testcase_39 AC 119 ms
6,940 KB
testcase_40 AC 6 ms
6,940 KB
testcase_41 AC 122 ms
6,940 KB
testcase_42 AC 123 ms
6,944 KB
testcase_43 AC 120 ms
6,940 KB
testcase_44 AC 122 ms
6,944 KB
testcase_45 AC 121 ms
6,944 KB
testcase_46 AC 119 ms
6,940 KB
testcase_47 AC 122 ms
6,940 KB
testcase_48 AC 120 ms
6,940 KB
testcase_49 AC 121 ms
6,940 KB
testcase_50 AC 119 ms
6,944 KB
testcase_51 AC 121 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ULL M=1000000007,D=1<<25,
T[] = {
	1,361946029,117175975,532814826,
	638916270,709912685,565479858,534784668,
	864357307,580002085,988122582,626052914,
	711403642,930569788,928062158,782871805,
	373979365,75908005,861919911,973727253,
	963971145,892153437,976333508,204474745,
	183143523,224645330,885152995,514060757,
	894672548,683957845
};

int main(){
	ULL x=0; cin>>x;
	x=min(x,M);
	ULL ans=T[x/D];
	rep(i,x%D) ans=ans*(x-i)%M;
	cout<<ans<<endl;
	return 0;
}
0