문제풀이/Baekjoon codeplus

[백준][정수론 및 조합론] 2004. 조합 0의 개수(파이썬/Python)

얄루몬 2021. 10. 8. 14:41

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


def two_count(n):
    two = 0
    while n != 0:
        n = n // 2
        two += n
    return two

def five_count(n):
    five = 0
    while n != 0:
        n = n // 5
        five += n
    return five

print(min(two_count(n) - two_count(n - m) - two_count(m), five_count(n) - five_count(n - m) - five_count(m)))