728x90
https://www.acmicpc.net/problem/1676
1676번: 팩토리얼 0의 개수
N!에서 뒤에서부터 처음 0이 아닌 숫자가 나올 때까지 0의 개수를 구하는 프로그램을 작성하시오.
www.acmicpc.net
import math
n = int(input())
s = str(math.factorial(n))
if s[-1] != '0':
print(0)
else:
cnt = 0
for i in range(len(s)-1,-1,-1):
if s[i] == '0':
cnt += 1
else:
break
print(cnt)
반응형
'전.py' 카테고리의 다른 글
[python] 백준 17626 Four Squares (0) | 2022.02.14 |
---|---|
[python] 백준 1764 듣보잡 (0) | 2022.02.14 |
[python] 백준 11723 집합 (0) | 2022.02.14 |
[python] 백준 1541 잃어버린 괄호 (0) | 2022.02.14 |
[python] 문자열 재정렬 (0) | 2022.02.14 |