알고리즘/백준
백준 2839: 설탕 배달 (Python)
sssbin
2021. 8. 30. 21:11
https://www.acmicpc.net/problem/2839
2839번: 설탕 배달
상근이는 요즘 설탕공장에서 설탕을 배달하고 있다. 상근이는 지금 사탕가게에 설탕을 정확하게 N킬로그램을 배달해야 한다. 설탕공장에서 만드는 설탕은 봉지에 담겨져 있다. 봉지는 3킬로그
www.acmicpc.net
n = int(input())
res = 0
k = n
cnt = 0
while res == 0:
if k % 5 == 0:
res = k // 5 + cnt
else:
k -= 3
cnt += 1
if k == 0:
res = n // 3
if k < 0:
res = -1
print(res)
n = int(input())
res = 0
while True:
if n % 5 == 0:
res += n // 5
break
else:
n -= 3
res += 1
if n < 0:
res = -1
break
print(res)