結果

問題 No.502 階乗を計算するだけ
ユーザー 0w10w1
提出日時 2017-04-10 16:06:23
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 2,495 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 79,004 KB
最終ジャッジ日時 2023-09-25 06:47:50
合計ジャッジ時間 7,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,332 KB
testcase_01 AC 71 ms
71,568 KB
testcase_02 AC 71 ms
71,200 KB
testcase_03 AC 69 ms
71,204 KB
testcase_04 AC 70 ms
71,384 KB
testcase_05 AC 72 ms
71,528 KB
testcase_06 AC 70 ms
71,360 KB
testcase_07 AC 70 ms
71,400 KB
testcase_08 AC 71 ms
71,268 KB
testcase_09 AC 71 ms
71,304 KB
testcase_10 AC 71 ms
71,128 KB
testcase_11 AC 71 ms
71,392 KB
testcase_12 AC 71 ms
71,056 KB
testcase_13 AC 70 ms
71,208 KB
testcase_14 AC 71 ms
71,200 KB
testcase_15 AC 70 ms
71,448 KB
testcase_16 AC 70 ms
71,472 KB
testcase_17 AC 69 ms
71,408 KB
testcase_18 AC 69 ms
71,264 KB
testcase_19 AC 71 ms
71,624 KB
testcase_20 AC 70 ms
71,496 KB
testcase_21 AC 69 ms
71,440 KB
testcase_22 AC 80 ms
75,828 KB
testcase_23 AC 76 ms
75,612 KB
testcase_24 AC 77 ms
75,704 KB
testcase_25 AC 74 ms
75,780 KB
testcase_26 AC 76 ms
75,880 KB
testcase_27 AC 75 ms
75,948 KB
testcase_28 AC 77 ms
75,700 KB
testcase_29 AC 76 ms
75,952 KB
testcase_30 AC 81 ms
75,868 KB
testcase_31 AC 78 ms
75,952 KB
testcase_32 AC 116 ms
75,824 KB
testcase_33 AC 144 ms
75,724 KB
testcase_34 AC 139 ms
75,700 KB
testcase_35 AC 143 ms
75,848 KB
testcase_36 AC 109 ms
75,852 KB
testcase_37 AC 143 ms
75,560 KB
testcase_38 AC 104 ms
75,876 KB
testcase_39 AC 135 ms
76,004 KB
testcase_40 AC 85 ms
75,556 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = int( 1e9 + 7 )

'''
known = {}
f = 1
for i in range( 1, int( 1e9 ), 1 ):
  f = f * i % MOD
  if i >= int( 1e7 ) and i % int( 1e7 ) == 0:
    known.update( { i : f } )
'''

known = { 0: 1, 320000000: 30977140, 820000000: 629786193, 740000000: 375297772, 470000000: 909210595, 200000000: 933245637, 940000000: 83868974, 400000000: 429277690, 130000000: 623534362, 870000000: 256473217, 600000000: 724464507, 330000000: 522049725, 60000000: 27368307, 800000000: 203191898, 530000000: 256141983, 260000000: 135498044, 730000000: 663307737, 460000000: 275105629, 190000000: 109838563, 930000000: 778983779, 660000000: 769795511, 390000000: 917084264, 120000000: 661224977, 860000000: 116667533, 10000000: 682498929, 590000000: 131772368, 50000000: 67347853, 790000000: 748510389, 520000000: 608823837, 250000000: 112390913, 990000000: 847549272, 720000000: 852304035, 450000000: 462639908, 180000000: 547665832, 920000000: 193781724, 650000000: 92255682, 380000000: 940567523, 110000000: 281863274, 850000000: 823845496, 580000000: 848924691, 310000000: 128487469, 40000000: 723816384, 780000000: 624500515, 510000000: 97830135, 240000000: 136026497, 980000000: 377329025, 710000000: 435887178, 440000000: 780072518, 170000000: 66404266, 20000000: 491101308, 670000000: 373745190, 910000000: 172114298, 640000000: 903466878, 370000000: 148528617, 100000000: 927880474, 840000000: 814362881, 570000000: 811575797, 300000000: 668123525, 30000000: 76479948, 770000000: 671734977, 500000000: 733333339, 230000000: 268838846, 970000000: 492741665, 700000000: 957939114, 430000000: 568392357, 160000000: 195888993, 900000000: 586445753, 630000000: 456152084, 360000000: 189239124, 90000000: 888050723, 830000000: 672850561, 560000000: 637939935, 290000000: 500780548, 760000000: 624148346, 490000000: 703397904, 220000000: 368925948, 270000000: 217544623, 960000000: 965785236, 690000000: 825871994, 420000000: 358655417, 150000000: 261384175, 890000000: 245795606, 620000000: 326159309, 350000000: 386027524, 80000000: 199888908, 550000000: 696628828, 280000000: 419363534, 750000000: 217598709, 480000000: 99199382, 210000000: 724691727, 950000000: 315103615, 680000000: 606241871, 410000000: 996164327, 140000000: 970055531, 880000000: 627655552, 610000000: 272814771, 340000000: 309058615, 70000000: 625544428, 810000000: 423951674, 540000000: 141827977}

N = int( input() )
ans = known[ N - N % int( 1e7 ) ]
for i in range( N - N % int( 1e7 ) + 1, N + 1, 1 ):
  ans = ans * i % MOD
print( ans )
0