Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
非打表,水题就是用来贴代码的(^_^)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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator