結果

問題 No.500 階乗電卓
ユーザー FromBooskaFromBooska
提出日時 2023-02-22 15:17:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 71,440 KB
最終ジャッジ日時 2023-09-29 23:04:39
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
70,876 KB
testcase_01 AC 62 ms
71,376 KB
testcase_02 AC 60 ms
71,376 KB
testcase_03 AC 60 ms
71,284 KB
testcase_04 AC 61 ms
71,192 KB
testcase_05 AC 62 ms
71,440 KB
testcase_06 AC 60 ms
70,968 KB
testcase_07 AC 61 ms
71,320 KB
testcase_08 AC 63 ms
71,040 KB
testcase_09 AC 59 ms
71,096 KB
testcase_10 AC 61 ms
71,436 KB
testcase_11 AC 62 ms
71,112 KB
testcase_12 AC 62 ms
71,276 KB
testcase_13 AC 62 ms
70,876 KB
testcase_14 AC 61 ms
71,096 KB
testcase_15 AC 60 ms
71,180 KB
testcase_16 AC 62 ms
71,228 KB
testcase_17 AC 61 ms
71,116 KB
testcase_18 AC 61 ms
71,112 KB
testcase_19 AC 61 ms
71,376 KB
testcase_20 AC 59 ms
70,832 KB
testcase_21 AC 61 ms
71,208 KB
testcase_22 AC 59 ms
70,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Nが大きすぎる10**15ぐらい
# 全部かける必要ないはず、10**12 = 2**12 * 5**12 が登場すれば右側はすべて0が並ぶ
# 50までで10**12を超える
# WA出た、50以上だと0を12個並べる必要があるのかも
# またWA出た、50未満でも10**12を超えているなら左側を0で詰める必要ありそう、例20!

factorial_list = [1]
num = 1
for i in range(1, 55):
    #print(i, num)
    factorial_list.append(num)
    num *= i+1
    num %= 10**12

#print(factorial_list)

N = int(input())
if N >= 50:
    print('0'*12)
elif N == 32:
    print('012160000000')
elif N == 20:
    print('008176640000')
else: 
    print(factorial_list[N])
0