Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int[] coins = new int[] { 1, 5, 10, 25, 50 };
- while (true) {
- String num1 = in.nextLine();
- if (num1.isEmpty()) {
- break;
- }
- int num = Integer.parseInt(num1);
- int[][] matriz = new int[5][num + 1];
- for (int i = 0; i <= num; i++) {
- matriz[0][i] = 1;
- }
- for (int i = 1; i <= 4; i++) {
- for (int j = 0; j < num + 1; j++) {
- int add = 0;
- if (j - coins[i] >= 0) {
- add = matriz[i][j - coins[i]];
- }
- matriz[i][j] = matriz[i - 1][j] + add;
- }
- }
- System.out.println([matriz.length - 1][num]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement