結果

問題 No.500 階乗電卓
ユーザー yoshi_kyoshi_k
提出日時 2017-09-17 04:45:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,620 KB
実行使用メモリ 8,244 KB
最終ジャッジ日時 2023-09-07 08:44:37
合計ジャッジ時間 1,261 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,152 KB
testcase_01 AC 13 ms
8,100 KB
testcase_02 AC 14 ms
8,244 KB
testcase_03 AC 12 ms
8,156 KB
testcase_04 AC 12 ms
7,856 KB
testcase_05 AC 13 ms
7,884 KB
testcase_06 AC 12 ms
7,800 KB
testcase_07 AC 13 ms
7,860 KB
testcase_08 AC 14 ms
7,872 KB
testcase_09 AC 12 ms
7,804 KB
testcase_10 AC 13 ms
7,828 KB
testcase_11 AC 13 ms
7,840 KB
testcase_12 AC 13 ms
7,948 KB
testcase_13 AC 13 ms
7,948 KB
testcase_14 AC 13 ms
7,880 KB
testcase_15 AC 12 ms
7,804 KB
testcase_16 AC 13 ms
8,240 KB
testcase_17 AC 13 ms
8,188 KB
testcase_18 AC 12 ms
8,212 KB
testcase_19 AC 12 ms
8,092 KB
testcase_20 AC 13 ms
8,156 KB
testcase_21 AC 13 ms
8,048 KB
testcase_22 AC 13 ms
8,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

n = int(input())
if n >= 50:
    print("%012d" % 0)
    sys.exit()

mod = int(1e12)

ans = 1
full_digit = False
for i in range(1, n+1):
    ans *= i
    if ans / mod > 1:
        full_digit = True
    ans %= mod

if full_digit:
    print("%012d" % ans)
else:
    print(ans)
0