쏘ing
[Python] 백준 1676 팩토리얼 0의 개수 본문
https://www.acmicpc.net/problem/1676
풀이 1
num = int(input())
count = 0
temp = 1
# 팩토리얼 값 계산
for i in range (num):
temp *= (i + 1)
temp = list(map(int, str(temp)))
# 0 개수 찾기
while (temp[-1] == 0):
count += 1
temp.pop()
print(count)
풀이 2
# 5의 개수로 찾기
# 5 제곱은 0의 개수가 두개, 세제곱은 세개 증가하므로 따로 더해줘야 함
num = int(input())
print(num // 5 + num // 25 + num // 125)
'알고리즘 > CLASS 3' 카테고리의 다른 글
[Python] 백준 1764 듣보잡 (0) | 2022.02.21 |
---|---|
[Python] 백준 17219 비밀번호 찾기 (0) | 2022.02.21 |
[Python] 백준 1620 나는야 포켓몬 마스터 이다솜 (0) | 2022.02.21 |
[Python] 백준 9375 패션왕 신해빈 (0) | 2022.02.21 |
[Python] 백준 11723 집합 (0) | 2022.02.08 |
Comments