結果

問題 No.3045 反復重み付き累積和
ユーザー gew1fw
提出日時 2025-06-12 12:56:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 54,364 KB
最終ジャッジ日時 2025-06-12 13:02:03
合計ジャッジ時間 3,472 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())

def count_p_in_factorial(n, p):
    count = 0
    while n > 0:
        n = n // p
        count += n
    return count

count_2 = count_p_in_factorial(n, 2)
count_5 = count_p_in_factorial(n, 5)

m_count_2 = 0
temp = m
while temp % 2 == 0 and temp != 0:
    m_count_2 += 1
    temp = temp // 2

m_count_5 = 0
temp = m
while temp % 5 == 0 and temp != 0:
    m_count_5 += 1
    temp = temp // 5

total_2 = count_2 + m_count_2
total_5 = count_5 + m_count_5

print(min(total_2, total_5))
0