Skip to content

Commit d593c52

Browse files
committed
📝 [ 백준 ] Silver : 11047. 동전 0
1 parent f21537c commit d593c52

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

Baekjoon/Python/02_Silver/11047.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# [ 백준 ] 11047번: 동전 0
2+
3+
def solution() -> None:
4+
N, K = list(map(int, input().split(" ")))
5+
A: list[int] = []
6+
for _ in range(N):
7+
coin: int = int(input())
8+
if coin <= K:
9+
A.insert(0, coin)
10+
11+
answer: int = 0
12+
for coin in A:
13+
answer += (K // coin)
14+
K %= coin
15+
16+
print(answer)
17+
18+
19+
if __name__ == "__main__":
20+
import io
21+
import unittest.mock
22+
23+
24+
def test_example_case() -> None:
25+
with unittest.mock.patch("builtins.input", side_effect=[
26+
"10 4200",
27+
"1",
28+
"5",
29+
"10",
30+
"50",
31+
"100",
32+
"500",
33+
"1000",
34+
"5000",
35+
"10000",
36+
"50000",
37+
]):
38+
with unittest.mock.patch("sys.stdout", new_callable=io.StringIO) as test_stdout:
39+
solution()
40+
41+
assert test_stdout.getvalue() == "6\n"
42+
43+
44+
test_example_case()
45+

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,13 @@
12971297
<td> <a href="https://velog.io/@dev_taehyun/algorithm-baekjoon-2839"> [ 알고리즘 ] 백준 2839번: 설탕 배달 </a> </td>
12981298
<td> 2022. 06. 16 </td>
12991299
</tr>
1300+
<tr align="left">
1301+
<td> <a href="https://www.acmicpc.net/problem/11047"> 11047번: 동전 0 </a> </td>
1302+
<td> 그리디 알고리즘 </td>
1303+
<td> <a href="./Baekjoon/Python/02_Silver/11047.py"> 11047.py </a> </td>
1304+
<td> <a href="https://velog.io/@dev_taehyun/algorithm-baekjoon-11047"> [ 알고리즘 ] 백준 11047번: 동전 0 </a> </td>
1305+
<td> 2022. 06. 17 </td>
1306+
</tr>
13001307
</table>
13011308

13021309
</details>

0 commit comments

Comments
 (0)