https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PsIl6AXIDFAUq
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
www.swexpertacademy.com
풀이
화폐단위를 미리 배열에 넣어두고 차례대로 나눠주며 count를 해줬다.
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for(int tc=1; tc<=T; tc++) {
int N = Integer.parseInt(br.readLine());
int[] count = new int[8];
int[] money = {50000, 10000, 5000, 1000, 500, 100, 50, 10};
for(int i=0; i<8; i++) {
if(N >= money[i]) { //돈이 화폐단위보다 같거나 클때만 나눠준다.
int cnt = N/money[i];
count[i] = cnt;
N -= cnt*money[i];
}
}
System.out.println("#"+tc);
for(int i=0; i<8; i++) {
System.out.print(count[i]+" ");
}
System.out.println();
}
}
}
'SWEA > D2' 카테고리의 다른 글
| [SWEA] 1961. 숫자 배열 회전 (0) | 2019.05.14 |
|---|---|
| [SWEA] 1974. 스도쿠 검증 (0) | 2019.05.03 |
| [SWEA] 1979. 어디에 단어가 들어갈 수 있을까 (0) | 2019.05.02 |
| [SWEA] 1976. 시각 덧셈 (0) | 2019.05.02 |
| [SWEA] 1983. 조교의 성적 매기기 (0) | 2019.05.01 |