Created
January 2, 2020 01:31
-
-
Save dalcon10028/12155276b7402db538f0e34950f0723e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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