백준2720: 세탁소 사장 동혁
문제
https://www.acmicpc.net/problem/2720
문제 풀이
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
import java.util.*;
public class Main {
static final int[] coins = {25, 10, 5, 1};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] money = new int[n];
int[][] answer = new int[n][4];
for (int i = 0; i < n; i++) {
money[i] = sc.nextInt();
for (int j = 0; j < coins.length; j++) {
if (money[i] / coins[j] > 0) {
answer[i][j] = money[i] / coins[j];
money[i] %= coins[j];
}
if (money[i] == 0) {
break;
}
}
}
for (int[] nums : answer) {
for (int num : nums) {
System.out.print(num + " ");
}
System.out.println();
}
}
}
댓글남기기