ps:problems:boj:33532
목차
Efficient Printing
| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 33532 |
| 문제명 | Efficient Printing |
| 레벨 | 실버 2 |
| 분류 |
정수론 |
| 시간복잡도 | O(logn) |
| 인풋사이즈 | n<=10^18 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 32412KB / 32ms |
| 최고기록 | 32ms |
| 해결날짜 | 2026/03/31 |
풀이
- 팩토리얼 0의 개수 과 같은 문제. 르장드르 공식 (Legendre's formula)을 이용해서 N!을 소인수분해했을때 5의 지수를 구하면 된다. 시간복잡도는 O(logn)
코드
"""Solution code for "BOJ 33532. Efficient Printing".
- Problem link: https://www.acmicpc.net/problem/33532
- Solution link: http://www.teferi.net/ps/problems/boj/33532
Tags: [math]
"""
def main():
n = int(input())
count = 0
while n := n // 5:
count += n
print(count)
if __name__ == '__main__':
main()
ps/problems/boj/33532.txt · 마지막으로 수정됨: 2026/03/31 14:40 저자 teferi

토론