Http://acm.hust.edu.cn/vjudge/contest/127206#problem/L
The main effect of the topic:
Match numbers with matches, tell you the number of matches you need for each number, ask how many numbers you can spell with n roots, including one and many digits, and no leading zeros
Because the result of the title will be very large in Java
The code is to add a new number after the spelled number, so the first number cannot be zero, i.e. I and J cannot be zero at the same time.
And then when you output the result, if n is greater than or equal to 6 Plus a separate 0 case
Import Java.util.Scanner;
Import java.math.*;
public class Main {public static void main (string[] args) {Scanner sc=new Scanner (system.in);
BigInteger []dp=new biginteger[2001];
BigInteger []ans=new biginteger[2001];
int []c=new int[11];
c[0]=6;
c[1]=2;
c[2]=5;
c[3]=5;
c[4]=4;
c[5]=5;
c[6]=6;
c[7]=3;
c[8]=7;
c[9]=6;
for (int i=1;i<2001;i++) Dp[i]=biginteger.zero;
Dp[0]=biginteger.one; for (int i=0;i<2001;i++) {for (int j=0;j<=9;j++) {if (i!=0| |
j!=0) && (I+c[j]) <=2000) {Dp[i+c[j]]=dp[i+c[j]].add (dp[i]);
}} Ans[0]=biginteger.zero;
for (int i=1;i<=2000;i++) Ans[i]=ans[i-1].add (Dp[i]); while (Sc.hasnext ()) {int N=sc.nextint();
if (n<6) System.out.println (Ans[n]);
Else System.out.println (Ans[n].add (Biginteger.one));
} sc.close (); }
}