λ°μν
π€λ¬Έμ ν΄κ²°
-
S2 | μν
- μ§μ§ ν©ν 리μΌλ‘ ꡬν΄μ λ¬Έμ λ₯Ό ν΄κ²°νκ² λλ©΄ μκ°μ΄κ³Ό λ°μ
- λμλ¦¬κ° 0μ΄λΌλ κ²μ 10μ λ°°μ
- 10μ 2μ 5λ‘ κ΅¬μ±λμ΄ μμ
- 2μ 5 μ§μ΄ λ§μμΌ 10μ΄ λλ―λ‘ 2μ κ°μμ 5μ κ°μμ€ λ μμκ² 10μ κ°μμ΄λ€.
π»μμ€ μ½λ
N, M = map(int, input().split())
# μ§μ§ ν©ν 리μΌλ‘ ꡬν΄μ λ¬Έμ λ₯Ό ν΄κ²°νκ² λλ©΄ μκ°μ΄κ³Ό λ°μ
# λμλ¦¬κ° 0μ΄λΌλ κ²μ 10μ λ°°μ
# 10μ 2μ 5λ‘ κ΅¬μ±λμ΄ μμ
# 2μ 5 μ§μ΄ λ§μμΌ 10μ΄ λλ―λ‘ 2μ κ°μμ 5μ κ°μμ€ λ μμκ² 10μ κ°μμ΄λ€.
def count_number(n, k):
count = 0
while n:
n //= k
count += n
return count
five_count = count_number(N, 5) - count_number(M, 5) - count_number(N - M, 5)
two_count = count_number(N, 2) - count_number(M, 2) - count_number(N - M, 2)
answer = min(five_count, two_count)
print(answer)
πλ¬Έμ νμΈ
μΆμ²: BACKJOON ONLINE JUDGE
λ§ν¬: https://www.acmicpc.net/problem/2004
λ°μν
'Algorithm Problem > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[python] νλ‘κ·Έλλ¨Έμ€ - 3μ§λ² λ€μ§κΈ° (μκ° μ½λ μ±λ¦°μ§ μμ¦1) (2) | 2020.10.22 |
---|---|
[python] λ°±μ€ - 5430. AC (0) | 2020.10.18 |
[python] λ°±μ€ - 2110. 곡μ κΈ° μ€μΉ (4) | 2020.10.16 |
[python] λ°±μ€ - 1735. λΆμ ν© (0) | 2020.10.15 |
[python] λ°±μ€ - 1965. μμ λ£κΈ° (0) | 2020.10.14 |