結果

問題 No.502 階乗を計算するだけ
ユーザー myantamyanta
提出日時 2017-06-30 11:01:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 87 ms / 1,000 ms
コード長 916 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 23,168 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 06:42:58
合計ジャッジ時間 2,226 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>


using ll=long long;

#define MOD 1000000007

int table[]={
1,800304985,361946029,944323045,117175975,212131504,532814826,698398808,638916270,166114276,709912685,
309672260,565479858,952004841,534784668,667220314,864357307,104909388,580002085,624854174,988122582,
104372309,626052914,62200437,711403642,516388569,930569788,117111267,928062158,619843354,782871805,
531967768,373979365,38760888,75908005,339599190,861919911,410124462,973727253,391452566,963971145,
587953096,892153437,767810085,976333508,330000241,204474745,279527279,183143523,994918408,224645330,
809913797,885152995,118809938,514060757,58160791,894672548,767161925,683957845,373529632,
};


int main(void)
{
	ll n;

	while(scanf("%lld", &n)==1)
	{
		if(n>=MOD)
		{
			printf("0\n");
			continue;
		}

		ll r=table[n>>24];

		for(ll i=((n>>24)<<24)+1;i<=n;i++)
		{
			r=(r*(i%MOD))%MOD;
		}
		printf("%lld\n", r);
	}

	return 0;
}
0