标签:air 出现 ast 三角形 int ike ctrl 个人 ref
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 9128 | Accepted: 4471 |
Description
Input
Output
Sample Input
2 3 -1
Sample Output
2 5
Source
然后这个题目就是一个裸的卡特兰数,因为到后面爆了long long,所以这里直接用了java的大数
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { BigInteger [] a = new BigInteger [105]; a[0] = BigInteger.ONE; a[1] = BigInteger.ONE; for( int i = 2; i <= 101; i ++ ) { a[i] = a[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1)); } Scanner cin = new Scanner(System.in); while( cin.hasNext() ) { int n = cin.nextInt(); if( n == -1 ) { break; } System.out.println(a[n]); } } }
POJ2084 Game of Connections 卡特兰数 关于卡特兰数经典的几个问题
标签:air 出现 ast 三角形 int ike ctrl 个人 ref
原文地址:https://www.cnblogs.com/l609929321/p/9320506.html