http://acm.hdu.edu.cn/showproblem.php?pid=1134

在上一题的基础上加个-1跳出的判断、、、

View Code
import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner cin=new Scanner (new BufferedInputStream(System.in));
        BigInteger[] f=new BigInteger[103];
        f[0]=f[1]=f[2]=BigInteger.valueOf(1);
        for(int i=2;i<102;i++)
            f[i+1]=BigInteger.valueOf(4).multiply(BigInteger.valueOf(i)).subtract(BigInteger.valueOf(6)).multiply(f[i]).divide(BigInteger.valueOf(i));
        while(cin.hasNext())
        {
            int n=cin.nextInt();
            if(n==-1)break;
            System.out.println(f[n+2]);
        }
    }
}