๋ฐ์ํ
๋ฐฑ์ค 2839๋ฒ [์คํ๋ฐฐ๋ฌ]
ํ์ด)
n=int(input())
cnt = 0
for x in range(n//5,-1,-1) :
n_ = n - (5*x)
if n_%3 == 0 :
cnt+= (n_//3)
cnt+= x
print(cnt)
break
if cnt == 0 :
print(-1)
728x90
๋ฐ์ํ
'๋ฐฑ์ค & ํ๋ก๊ทธ๋๋จธ์ค > greedy' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 1541] [greedy] ์์ด๋ฒ๋ฆฐ ๊ดํธ (0) | 2021.04.18 |
---|---|
[๋ฐฑ์ค 1931] [greedy] ํ์์ค ๋ฐฐ์ โ (0) | 2021.04.18 |
[๋ฐฑ์ค 11047] [greedy] ๋์ 0 (0) | 2021.04.17 |
[๋ฐฑ์ค 11399] [greedy] ATM (0) | 2021.04.17 |