杭电 4165 Pills
来源:互联网 发布:网络的外部性 编辑:程序博客网 时间:2024/05/16 09:23
Pills
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): Accepted Submission(s):
Problem Description
Aunt Lizzie takes half a pill of a certain medicine every day. She starts with a bottle that contains N pills.
On the first day, she removes a random pill, breaks it in two halves, takes one half and puts the other half back into the bottle.
On subsequent days, she removes a random piece (which can be either a whole pill or half a pill) from the bottle. If it is half a pill, she takes it. If it is a whole pill, she takes one half and puts the other half back into the bottle.
In how many ways can she empty the bottle? We represent the sequence of pills removed from the bottle in the course of 2N days as a string, where the i-th character is W if a whole pill was chosen on the i-th day, and H if a half pill was chosen (0 <= i < 2N). How many different valid strings are there that empty the bottle?
On the first day, she removes a random pill, breaks it in two halves, takes one half and puts the other half back into the bottle.
On subsequent days, she removes a random piece (which can be either a whole pill or half a pill) from the bottle. If it is half a pill, she takes it. If it is a whole pill, she takes one half and puts the other half back into the bottle.
In how many ways can she empty the bottle? We represent the sequence of pills removed from the bottle in the course of 2N days as a string, where the i-th character is W if a whole pill was chosen on the i-th day, and H if a half pill was chosen (0 <= i < 2N). How many different valid strings are there that empty the bottle?
Input
The input will contain data for at most 1000 problem instances. For each problem instance there will be one line of input: a positive integer N <= 30, the number of pills initially in the bottle. End of input will be indicated by 0.
Output
For each problem instance, the output will be a single number, displayed at the beginning of a new line. It will be the number of different ways the bottle can be emptied.
Sample Input
61423300
Sample Output
132114253814986502092304
AC代码如下:
#include<stdio.h>int main(){ __int64 f[31],n,i; for(f[1]=1,i=2;i<=30;i++) f[i]=(f[i-1]*(4*i-2))/(i+1); while(~scanf("%I64d",&n)&&n) { printf("%I64d\n",f[n]); } return 0;}
0 0
- 杭电 4165 Pills
- HDU 4165(Pills )
- HDU 4165 Pills
- HDU 4165Pills
- Pills - HDU 4165 递推打表
- HDU 4165 Pills
- HDU 4165 Pills
- hdu 4165 Pills
- hdu 4165 Pills
- pills
- HDU 4165 Pills (dp解法)
- HDU 4165 Pills (DP卡特兰数列)
- HDU 4165 Pills (卡特兰数)
- HDU 4165 Pills【卡特兰数】
- hdoj.4165 Pills【卡特兰数列】 2015/08/27
- HDU 4165 Pills(DP/记忆化搜索/卡塔兰数)
- ZZULI 1595 Pills
- HDU4165 (卡特兰数列) Pills
- Lucene:基于Java的全文检索引擎简介
- 编写一个截取字符串的函数
- HDU 2844 Coins
- mongodb
- 2.5.线程的同步和协作_锁的公平性
- 杭电 4165 Pills
- Cobertura原理
- 天气api
- linux访问windows共享文件夹
- 云计算读书笔记2
- hdu2818Building Block
- 笔试题:如何判断单链表是否存在环
- 5月5日—人生
- C4.5算法