Skip to content

Commit eabba53

Browse files
authored
#34 : 2839_설탕 배달
#34 : Week8_예원이티
1 parent ab2fe8d commit eabba53

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

이티예원/2839_설탕 배달.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
N = int(input())
2+
bag = 0
3+
4+
while N >= 0:
5+
6+
# 봉지 수를 최소로 만들기 위해서
7+
# 5kg 봉지 수를 최대로
8+
# 3kg 봉지 수를 최소로 만들어야 함
9+
10+
# 5의 배수인 경우
11+
if N % 5 == 0:
12+
bag += int(N // 5)
13+
print(bag)
14+
break
15+
16+
# 5의 배수가 아닌 경우
17+
# 5의 배수로 만들기 위해서
18+
N -= 3 # 배달 해야 하는 설탕 -3kg
19+
bag += 1 # 가져가야하는 봉지 수 +1
20+
# 1. 5의 배수가 될 때까지
21+
# 2. 또는 정확하게 N킬로그램으로 만들 수 없음이 확인될 때 까지 반복
22+
23+
else:
24+
print(-1)

0 commit comments

Comments
 (0)