Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Created January 2, 2020 01:31
Show Gist options
  • Select an option

  • Save dalcon10028/12155276b7402db538f0e34950f0723e to your computer and use it in GitHub Desktop.

Select an option

Save dalcon10028/12155276b7402db538f0e34950f0723e to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt(); // 종류
int K = sc.nextInt(); // 맞추려는 값
int []coin = new int[N];
int sum=0; // 필요한 동전개수의 합 (답)
for (int i=N-1; i>=0; i--) // 내림차순으로 종류 입력
coin[i] = sc.nextInt();
sc.close();
for(int i=0; i<N; i++){
sum+= K/coin[i];
K%=coin[i];
}
System.out.print(sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment