๋ฐฑ์ค€ & ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/greedy

[๋ฐฑ์ค€ 2839] [greedy] ์„คํƒ•๋ฐฐ๋‹ฌ

_cactus 2021. 4. 17. 11:18
๋ฐ˜์‘ํ˜•

๋ฐฑ์ค€ 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
๋ฐ˜์‘ํ˜•