File tree 2 files changed +52
-0
lines changed
Baekjoon/Python/02_Silver
2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change 1297
1297
<td> <a href="https://velog.io/@dev_taehyun/algorithm-baekjoon-2839"> [ 알고리즘 ] 백준 2839번: 설탕 배달 </a> </td>
1298
1298
<td> 2022. 06. 16 </td>
1299
1299
</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 >
1300
1307
</table >
1301
1308
1302
1309
</details >
You can’t perform that action at this time.
0 commit comments