結果

問題 No.3045 反復重み付き累積和
ユーザー gew1fw
提出日時 2025-06-12 18:18:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2025-06-12 18:18:19
合計ジャッジ時間 3,886 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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