반응형
문제 이해
아이디어
코드
import java.io.*;
import java.util.*;
public class Solution {
static int Money;
static int[] cnt;
static final int[] type = new int[] {50000,10000,5000,1000,500,100,50,10};
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine()," ");
int T = stoi(st.nextToken());
for (int tc = 1; tc <= T; ++tc) {
cnt = new int[8];
st = new StringTokenizer(br.readLine()," ");
Money = stoi(st.nextToken());
for(int i=0;i<8;++i) calc(type[i],i);
System.out.println("#"+tc+" ");
for(int i=0;i<8;++i) {
System.out.print(cnt[i]+" ");
}
System.out.println();
}
}
static void calc(int range, int index) {
if(Money >= range) {
cnt[index] = Money / range;
Money %= range;
}
}
static int stoi(String s) {
return Integer.parseInt(s);
}
}
집사는개발자가되고파
choppadontbiteme.tistory.com
반응형
'Algorithm > SWEA' 카테고리의 다른 글
[SWEA] 1974. 스도쿠 검증 D2 JAVA (0) | 2021.03.26 |
---|---|
[SWEA] 1961. 숫자 배열 회전 D2 JAVA (0) | 2021.03.25 |
[SWEA] 1966. 숫자를 정렬하자 D2 JAVA (0) | 2021.03.25 |
[SWEA] 1959. 두 개의 숫자열 D2 JAVA (0) | 2021.03.25 |
[SWEA] 1946. 간단한 압축풀기 D2 JAVA (0) | 2021.03.25 |