Created
January 20, 2013 22:05
-
-
Save zeroDivisible/4582113 to your computer and use it in GitHub Desktop.
This is simple solution to Problem #31 on Project Euler.
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 problem31 { | |
final static int TOTAL = 200; | |
public static void main(String[] args) { | |
int[] coins = {1, 2, 5, 10, 20, 50, 100, 200}; | |
int[] ways = new int[TOTAL + 1]; | |
ways[0] = 1; | |
for(int coin: coins) | |
for(int j = coin; j <= TOTAL; j++) | |
ways[j] += ways[j - coin]; | |
System.out.println("Result: " + ways[TOTAL]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment