[백준] 2004번 : 조합 0의 개수 - Python(파이썬)

강재원·2022년 10월 21일
0

[코딩테스트] Python

목록 보기
138/200



https://www.acmicpc.net/problem/2004

n,m=map(int,input().split())
count2=0
count5=0
i=2
while i<=n:
    count2+=n//i
    i*=2
i=2
while i<=m:
    count2-=m//i
    i*=2
i=2
while i<=n-m:
    count2-=(n-m)//i
    i*=2
i=5
while i<=n:
    count5+=n//i
    i*=5
i=5
while i<=m:
    count5-=m//i
    i*=5
i=5
while i<=n-m:
    count5-=(n-m)//i
    i*=5
print(count2 if(count2<=count5) else count5)
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글