卖票
来源:互联网 发布:值得买的电子产品知乎 编辑:程序博客网 时间:2024/05/16 19:26
Problem DescriptionOne day, little pig wants to go to the park for fun. He has just one piece of five dollar and luckily the park sells the ticket for five dollar. When he got to the park, there are 2*n people waited in one line for ticket. And just by chance, there were n people have one piece of ten dollar and n people has one piece of five dollar (not include little pig).The little pig watched the park seller to sell tickets and after a while, 2*n people got their tickets and by another chance, all the people who had 10 dollar had their charge and the seller didn’t use their park’s charge!Little pig wanted to know how many kinds of permutation that these 2*n people formed?InputThere are multiply test cases in this problem. One integer n(1<=n<=30) in one line.The input will be terminated by n=0.OutputPrint one integer in one line which is the number of permutation.Sample Input20Sample Output2//题意:有2*n个人,其中n个人有10元,n个人有5元,一种商品价格为5元。求不需要找零钱的方案种数。//题解:由题意可以推出 F[1] = 1, F[2]=2,F[3] = 5, F[4] =14.从而发现这一列数符合卡特兰数列。//标程:#include<stdio.h>#include<string.h>__int64 Catelan[33];void fun(){ int i,j; memset(Catelan,0,sizeof(Catelan)); Catelan[0]=1,Catelan[1]=1; for(i=2;i<33;i++) { for(j=0;j<i;j++) Catelan[i]+=Catelan[j]*Catelan[i-1-j]; }}int main(){// freopen("a.txt","r",stdin); fun(); int n; while(scanf("%d",&n)==1&&n) printf("%I64d\n",Catelan[n]); return 0;}
0 0
- 卖票
- 卖票
- 卖票
- 卖票
- 线程,卖票
- *简单卖票
- 卖票线程
- 多线程卖票
- 卖票系统
- 卖票系统
- 卖票——多线程模拟卖票系统
- JAVA线程实例-----卖票
- 电影院卖票问题
- 线程学习之卖票
- Java 多线程卖票演示
- 多线程,卖票系统
- 卖票系统同步问题
- 多线程之卖票程序
- Device Registration and Initialization
- IOCP一:AcceptEx
- ZOJ 3787 Access System 模拟
- 界面超漂亮的桌面时钟
- 固定DIV不随滚动条滚动
- 卖票
- STL源码剖析 算法 set
- 查询oracle隐含参数
- 最长不下降子序列
- hdu 1198(再续并查集)
- Android无法访问本地服务器(localhost)的解决方案
- Xilinx FPGA的约束设计和时序分析总结 (转)
- 关于计算数学多项式的代码
- peewee连接mysql中文数据编码