We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;importjava.math.*;publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */{BigIntegertable[]=newBigInteger[100001];intcoin[]=newint[]{1,2,5,10,20,50,100,200};for(inti=0;i<table.length;i++){table[i]=BigInteger.ZERO;}table[0]=BigInteger.ONE;for(inti=0;i<8;i++){for(intj=coin[i];j<table.length;j++){table[j]=table[j].add(table[j-coin[i]]);}}Scannersc=newScanner(System.in);intnum=Integer.parseInt(sc.nextLine());for(inti=0;i<num;i++){inttem=Integer.parseInt(sc.nextLine());System.out.println(table[tem].mod(BigInteger.valueOf(1000000007)));}}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #31: Coin sums
You are viewing a single comment's thread. Return to all comments →
Java Code