SWEA_1970) 쉬운 거스름돈
SWEA
# D2
1970) 쉬운 거스름돈 (19.10.04)
문제 링크 (SW Expert Academy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import java.io.*;
public class Solution {
public static void mon(int n, int[] money) {
int cnt = 0;
while(n>=50000) {
n = n-50000;
cnt = cnt+1;
}
money[0] = cnt;
cnt = 0;
while(n>=10000) {
n = n-10000;
cnt = cnt+1;
}
money[1] = cnt;
cnt = 0;
while(n>=5000) {
n = n-5000;
cnt = cnt+1;
}
money[2] = cnt;
cnt = 0;
while(n>=1000) {
n = n-1000;
cnt = cnt+1;
}
money[3] = cnt;
cnt = 0;
while(n>=500) {
n = n-500;
cnt = cnt+1;
}
money[4] = cnt;
cnt = 0;
while(n>=100) {
n = n-100;
cnt = cnt+1;
}
money[5] = cnt;
cnt = 0;
while(n>=50) {
n = n-50;
cnt = cnt+1;
}
money[6] = cnt;
cnt = 0;
while(n>=10) {
n = n-10;
cnt = cnt+1;
}
money[7] = cnt;
}
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(br.readLine());
for(int i=1;i<=t;i++) {
int n = Integer.parseInt(br.readLine());
int[] money = new int[8];
mon(n, money);
bw.write("#" + i + "\n");
for(int j: money) bw.write(j + " ");
bw.write("\n");
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기