Skip to content

Commit 739b69c

Browse files
committed
[BOJ] #14916. 거스름돈 / 실버5 / 50분 / 성공
1 parent 2305b41 commit 739b69c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
n = int(input()) # 거스름돈 액수
5+
6+
# 예외처리
7+
if n == 1 or n == 3:
8+
print(-1)
9+
exit(0)
10+
11+
# 5로 나누어 떨어질 경우
12+
if n % 5 == 0:
13+
print(n // 5)
14+
15+
else:
16+
cnt = 0
17+
while n > 0:
18+
if (n >= 5) and ((n - 5) % 5 == 0 or (n - 5) % 2 == 0):
19+
n -= 5
20+
else:
21+
n -= 2
22+
23+
cnt += 1
24+
25+
print(cnt)

0 commit comments

Comments
 (0)