标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8690 Accepted Submission(s):
4548
1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 __int64 catalan[40]; 5 void catalans() 6 { 7 memset(catalan,0,sizeof(catalan)); 8 catalan[0]= catalan[1]= 1; 9 for(int i=2; i<= 35; i++) 10 { 11 for(int j=0; j< i; j++) 12 catalan[i]+=catalan[j]*catalan[i-j-1]; 13 } 14 } 15 int main() 16 { 17 int i,j,n,m; 18 int t=1; 19 catalans(); 20 while(cin>>n) 21 { 22 if(n==-1) 23 break; 24 cout<<t++<<" "<<n<<" "<<catalan[n]*2<<endl; 25 } 26 }
标签:
原文地址:http://www.cnblogs.com/pshw/p/5325109.html