1 import java.util.*; 2 import java.math.*; 3 public class Main 4 { 5 public static void main(String []args) 6 { 7 Scanner cin=new Scanner(System.in); 8 int i,n; 9 int count=1; 10 while(cin.hasNext()) 11 { 12 n=cin.nextInt(); 13 if(n==-1) 14 break; 15 BigInteger s1 = BigInteger.valueOf(1); 16 BigInteger s2 = BigInteger.valueOf(1); 17 for(i=1;i<=n;i++) 18 { 19 s1=s1.multiply(BigInteger.valueOf(2*n-i+1)); 20 s2=s2.multiply(BigInteger.valueOf(i)); 21 } 22 s1=s1.divide(BigInteger.valueOf(n+1)); 23 s1=s1.divide(s2); 24 s1=s1.multiply(BigInteger.valueOf(2)); 25 System.out.println(count+" "+n+" "+s1); 26 count++; 27 } 28 } 29 }
这个题目自己算了n=4的时候结果是28,发现n=3的时候结果是10,n=1的时候结果是2,就觉得这个题目和