摘要:
卡特兰数真是一个神奇的数字,很多组合问题的数量都和它有关系,例如: Cn= 长度为 2n的 Dyck words的数量。 Dyck words是由 n个 X和 n个 Y组成的字符串,并且从左往右数, Y的数量不超过 X,例如长度为 6的 Dyck words为: XXXYYY XYXXYY XYXYXY XXYYXY XXYXYY Cn= n对括号正确匹配组成的字符串数,例如 3对括号能够组成: ((())) ()(()) ()()() (())() (()()) Cn= n+1个数相乘,所有的括号方案数。例如, 4个数相乘的括号方案为: ((ab)c)d (a(bc))d (ab)(cd). 阅读全文
摘要:
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023该题就是求卡特兰数,只是处理的时候要用大数来处理,使用递推公式:h(n)=C(2n,n)/(n+1) (n=0,1,2,...)= A(2n,n)/(n+1)!改写我先求A(2n,n)然后除以(n+1)! 1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 5 using namespace std; 6 7 #define N 250 8 int a[N]; 9 10 void 阅读全文
摘要:
Train Problem ITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14413Accepted Submission(s): 5310Problem DescriptionAs the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because 阅读全文
摘要:
Buy the TicketTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3246Accepted Submission(s): 1350Problem DescriptionThe "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go t 阅读全文
摘要:
一开始想的时候吧那个搞错了,那个在同一层的时候对停留5S 1 #include <stdio.h> 2 #include <string.h> 3 4 int a[3005]; 5 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n) && n)10 {11 int i;12 long sum = 0;13 memset(a,0,sizeof(a));14 for(i = 1; i <= n; i++)15 scanf("%d",&a... 阅读全文