| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 9693 |
| 문제명 | 시파르 |
| 레벨 | 실버 4 |
| 분류 |
정수론 |
| 시간복잡도 | O(T*logn) |
| 인풋사이즈 | T<=?, n<=10^6 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 32412KB / 36ms |
| 최고기록 | 32ms |
| 해결날짜 | 2026/02/19 |
"""Solution code for "BOJ 9693. 시파르".
- Problem link: https://www.acmicpc.net/problem/9693
- Solution link: http://www.teferi.net/ps/problems/boj/9693
Tags: [number theory]
"""
import sys
from teflib import psutils
def exponent_of_prime_in_factorial(n: int, p: int):
"""Compute largest power of a prime p that divides factorial(n)."""
count = 0
while n:
n //= p
count += n
return count
@psutils.run_until_all_zero
@psutils.testcase_format('Case #{}: ')
def main():
N = int(sys.stdin.readline())
print(exponent_of_prime_in_factorial(N, 5))
if __name__ == '__main__':
main()