結果

問題 No.500 階乗電卓
ユーザー gew1fw
提出日時 2025-06-12 21:27:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 677 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 53,576 KB
最終ジャッジ日時 2025-06-12 21:29:01
合計ジャッジ時間 1,957 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

def count_factors(n, factor):
    count = 0
    while n > 0:
        n = n // factor
        count += n
    return count

N = int(input())

cnt2 = count_factors(N, 2)
cnt5 = count_factors(N, 5)
t = min(cnt2, cnt5)

if t >= 12:
    print(0)
else:
    mod = 10 ** 12
    product = 1
    for i in range(1, N + 1):
        x = i
        while x % 2 == 0:
            x = x // 2
        while x % 5 == 0:
            x = x // 5
        product = (product * x) % mod
    excess_2 = cnt2 - t
    excess_5 = cnt5 - t
    product = (product * pow(2, excess_2, mod)) % mod
    product = (product * pow(5, excess_5, mod)) % mod
    product = (product * (10 ** t)) % mod
    print(product)
0