-
-
Save bitcpf/9ac3344682a848d8bf05 to your computer and use it in GitHub Desktop.
This file contains 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
public class Q9_8 { | |
public static int Permcoin(int n, int coin){ | |
int next_coin = 0; | |
switch (coin){ | |
case 25: | |
next_coin = 10; | |
break; | |
case 10: | |
next_coin = 5; | |
break; | |
case 5: | |
next_coin = 1; | |
break; | |
case 1: | |
return 1; | |
} | |
int ways = 0; | |
for(int i =0; i*coin <= n;i++){ | |
ways += Permcoin(n - i*coin,next_coin); | |
} | |
return ways; | |
} | |
public static void main(String[] args){ | |
int testn = 100; | |
System.out.println(testn); | |
System.out.println(Permcoin(testn,25)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment