Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3-suhyun113 #12

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)