Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

非打表,水题就是用来贴代码的(^_^)

Posted by 1000010314 at 2012-04-19 07:58:29 on Problem 2084
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
    static Scanner cin=new Scanner(System.in);
    static PrintWriter cout=new PrintWriter(System.out, true);
    static BigInteger[] data=new BigInteger[101];

    static BigInteger getAnswer(int n)
    {
        if(data[n].equals(BigInteger.ZERO))
        {
            for(int i=0;i<n;i++)
            {
                data[n]=data[n].add(getAnswer(n-i-1).multiply(getAnswer(i)));
            }
        }
        return data[n];
    }

    public static void main(String[] args)
    {
        Arrays.fill(data,BigInteger.ZERO);
        int n;data[0]=data[1]=BigInteger.ONE;
        while(cin.hasNext())
        {
            n=cin.nextInt();
            cout.println(getAnswer(n));
        }
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator