무제
[백준] 1676번 팩토리얼 0의 개수 본문
1. 나의 풀이
통과한 풀이지만 모범답안을 보니 엉망이네
import sys
input = sys.stdin.readline
n = int(input())
array = [1]*501
for i in range(1, n+1):
array[i] = array[i-1]*i
answer = 0
while array[n] % 10 == 0:
array[n] = array[n] // 10
answer +=1
print(answer)
2. 좋은 풀이
와 10은 2x5이므로 5의 개수만 찾아내면 된다....
범위가 500까지므로 5의 3제곱수까지만 계산해주면 된다
이걸 어케 생각하는거지...
N = int(input())
print(N//5 + N//25 + N//125)'Study > Coding Test 오답노트' 카테고리의 다른 글
| [백준] 15990번 1,2,3 더하기 5 (0) | 2024.12.09 |
|---|---|
| [백준] 9095번 1,2,3 더하기 (0) | 2024.12.05 |
| [백준] 6588번 골드바흐의 추측 (0) | 2024.11.27 |
| [백준] 10820 문자열 분석 / 1463 1로 만들기 (0) | 2024.11.26 |
| [백준] 17299번 오등큰수 (0) | 2024.11.22 |
Comments