백준 - (# 2004)

Eon·2020년 11월 14일
0

Algorithm

목록 보기
55/70

https://www.acmicpc.net/problem/2004
nCm의 끝자리 0의 개수를 출력하는 프로그램을 작성하시오.

Code

def count_num(a,b):
    result = 0
    while a >= b:
        a = a//b
        result += a
    return result

n, m = map(int, input().split())
two_cnt = count_num(n,2)-count_num(n-m,2)-count_num(m,2)
five_cnt = count_num(n,5)-count_num(n-m,5)-count_num(m,5)

print(min(two_cnt, five_cnt))

참고
https://velog.io/@starteon/%EB%B0%B1%EC%A4%80-1676

profile
👨🏻‍💻 🏃🏻‍♂️ 🎶

0개의 댓글