D[i+c[j]]+=d[i] (C[j] is the number of matches required to spell J)
D[0]=1;
Don't forget to have a leading zero, so when I is zero, don't try to spell 0. Instead, add 1 to the answer (spell 0 separately) when n>=6.
Import java.util.*;import java.io.*;import java.math.*;p ublic class main{static biginteger[] d=new BigInteger[2010]; Static int[] C=new int[]{6,2,5,5,4,5,6,3,7,6};p ublic static void Main (string[] argc) {Scanner sc = new Scanner (New Buffere Dinputstream (system.in)), while (Sc.hasnext ()) {Arrays.fill (d,biginteger.zero); int n=sc.nextint ();d [0]= biginteger.one;for (int i=0;i<=n;++i) {for (int j=0;j<10;++j) {if ((i!=0 | | j!=0) && i+c[j]<=n) {D[i+c[j] ]=d[i+c[j]].add (D[i]);}} BigInteger ans=biginteger.zero;for (int i=1;i<=n;++i) {ans=ans.add (d[i]);} if (n>=6) {ans=ans.add (biginteger.one);} System.out.println (ans);} Sc.close (); }}
"Java" "High precision" "Recursive" uva-11375-matches