Matches UVA 11375

第一次用java,真心不错,感谢林威同学给我装的java虚拟机和Eclipse


import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	  static int MAXN = 2010;
	  public static void main(String[] args){
		    int ts;
		    int opt[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
		    BigInteger table[] = new BigInteger[MAXN];
		    BigInteger one = new BigInteger("1");
		    for(int i = 0; i <= MAXN-1; ++i)
		    	table[i] = new BigInteger("0");
		    for(int i = 1; i <= 9; ++i)
		    	table[opt[i]] = table[opt[i]].add(one);
		    for(int i = 1; i <= 2000; ++i)
		    	for(int j = 0; j <= 9; ++j)
		    		table[i+opt[j]] = table[i+opt[j]].add(table[i]);
		    table[6] = table[6].add(one);
		    for(int i = 1; i <= 2000; ++i)
		    	table[i] = table[i].add(table[i-1]);
		    Scanner sc = new Scanner(System.in);
		    while(sc.hasNextInt()){
		    	ts = sc.nextInt();
		    	System.out.println(table[ts]);
		    }
	  }	    
}




你可能感兴趣的:(Matches UVA 11375)