Skip to content

Commit

Permalink
Merge pull request #12 from AlgoLeadMe/3-suhyun113
Browse files Browse the repository at this point in the history
3-suhyun113
  • Loading branch information
suhyun113 committed Apr 11, 2024
2 parents 88eee6e + 874af29 commit 10a3af0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions suhyun113/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.03.25 | 그리디 | [체윑볡](https://school.programmers.co.kr/learn/courses/30/lessons/42862) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/2) |
| 2μ°¨μ‹œ | 2024.03.29 | μˆ˜ν•™ | [μ†Œμˆ˜ & νŒ°λ¦°λ“œλ‘¬](https://www.acmicpc.net/problem/1747) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/9) |
| 1μ°¨μ‹œ | 2024.03.25 | 그리디 | [체윑볡](https://school.programmers.co.kr/learn/courses/30/lessons/42862) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/2) |
| 2μ°¨μ‹œ | 2024.03.29 | μˆ˜ν•™ | [μ†Œμˆ˜ & νŒ°λ¦°λ“œλ‘¬](https://www.acmicpc.net/problem/1747) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/9) |
| 3μ°¨μ‹œ | 2024.04.02 | 그리디 | [κ±°μŠ€λ¦„λˆ](https://www.acmicpc.net/problem/14916) | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/12) |
20 changes: 20 additions & 0 deletions suhyun113/그리디/3-suhyun113.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
n = int(input()) # κ±°μŠ€λ¦„λˆ μ•‘μˆ˜
coin_count = 0 # λ™μ „μ˜ 개수
i = 0
while True: # λ¬΄ν•œλ£¨ν”„
# 2원보닀 5원이 더 큰 값이기 λ•Œλ¬Έμ—, λ™μ „μ˜ μ΅œμ†Œ 개수λ₯Ό ꡬ할 λ•Œ 5원뢀터 νŒλ³„ν•¨
if n % 5 == 0: # 5둜 λ‚˜λˆ„μ–΄ 떨어지면 5μ›μ˜ κ°œμˆ˜κ°€ μ΅œμ†Œ λ™μ „μ˜ 개수
coin_count += n // 5
break # μ΅œμ†Œ λ™μ „μ˜ κ°œμˆ˜μ΄λ―€λ‘œ λ°”λ‘œ 좜λ ₯
else: # 5의 배수 μ•„λ‹ˆλ©΄, κ±°μŠ€λ¦„λˆμ—μ„œ 2μ”© λΉΌλ©΄μ„œ 5둜 λ–¨μ–΄μ§€λŠ” 것을 찾음
n -= 2
coin_count += 1 # 5둜 λ‚˜λˆ λ–¨μ–΄μ§ˆ λ•Œλ§ˆλ‹€ λ™μ „μ˜ 개수 증가

# κ±°μŠ€λ¦„λˆμ—μ„œ 2원씩 λΉΌλ‹€κ°€ κ±°μŠ€λ¦„λˆμ΄ 0보닀 μž‘μ•„μ§€λ©΄ 더 이상 κ±°μŠ¬λŸ¬μ€„ 수 μ—†μŒ
if (n < 0):
break

if (n < 0):
print(-1)
else:
print(coin_count)

0 comments on commit 10a3af0

Please sign in to comment.