백준 알고리즘 - 11047 (동전 0)

aladin·2020년 8월 22일
0

백준알고리즘

목록 보기
12/18

문제

I.O

코드 및 해석

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Boj_11047 {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int N, K;
		
		N = Integer.parseInt(st.nextToken());
		K = Integer.parseInt(st.nextToken());
		
		int[] coin = new int[N];
		int i = coin.length - 1;
		int cnt = 0;
		
		for(int j = 0 ; j < coin.length ; j++) {
			coin[j] = Integer.parseInt(br.readLine());
		}
		
		while(K != 0) {
			while(K / coin[i] != 0) {
				cnt += K / coin[i];
				K %= coin[i];
			}
			i--;
		}		
		System.out.println(cnt);
	}
}

문제 및 사진출처

출처 - 백준 알고리즘_11047번

profile
컴공과 대학생의 개발노트

0개의 댓글