POJ 2084 Game of Connections
来源:互联网 发布:淘宝囤货 编辑:程序博客网 时间:2024/05/21 10:54
Game of Connections
Time Limit: 1000MS Memory Limit: 30000KTotal Submissions: 4839 Accepted: 2515
Description
This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, . . . , 2n - 1, 2n consecutively in clockwise order on the ground to form a circle, and then, to draw some straight line segments to connect them into number pairs. Every number must be connected to exactly one another.
And, no two segments are allowed to intersect.
It's still a simple game, isn't it? But after you've written down the 2n numbers, can you tell me in how many different ways can you connect the numbers into pairs? Life is harder, right?
And, no two segments are allowed to intersect.
It's still a simple game, isn't it? But after you've written down the 2n numbers, can you tell me in how many different ways can you connect the numbers into pairs? Life is harder, right?
Input
Each line of the input file will be a single positive number n, except the last line, which is a number -1.
You may assume that 1 <= n <= 100.
You may assume that 1 <= n <= 100.
Output
For each n, print in a single line the number of ways to connect the 2n numbers into pairs.
Sample Input
23-1
Sample Output
25
Source
Shanghai 2004 Preliminary
/*
卡特兰数 + 大数运算,一开始自己推公式得到的结论是:
f(2 * n) = f(0) * f(2 * n - 2) + f(2) * f(2 * n - 4) + f(4) * f(2 * n - 6) + ... + f(2 * n - 2) * f(0);
然后纯粹基于递推来算, 发现结果是对的,但是速度太慢,超时了。后来想了想,这不就是卡特兰数吗?呵呵,问题解决了
F(n) = F(0) * F(n - 1) + F(1) * F(n - 2) + ... + F(n - 1) * F(0) = C(2 * n, n) / (n + 1), F(0) = 1
代码很长,大部分是自己写的大数运算工具模板.实在不想用JAVA水了,没意思,哈哈
*/
- POJ 2084 Game of Connections
- poj 2084 Game of Connections
- POJ 2084 Game of Connections
- POJ-2084-Game of Connections
- poj 2084 Game of Connections
- poj 2084 Game of Connections
- [POJ] 2084 -> Game of Connections
- POJ 2084 Game of Connections
- poj 2084 Game of Connections
- POJ 2084 Game of Connections 笔记
- POJ-2084(Catalan数专题)(Game of Connections )
- POJ 2084 Game of Connections 卡特兰数
- POJ 2084 Game of Connections(卡特兰数,JAVA)
- POJ 2084 Game of Connections(JAVA练习)
- 卡特兰数:poj 2084 Game of Connections+hdu 1023
- Poj 2084 Game of Connections(高精度卡特兰数)
- POJ 2084:Game of Connections 大数+卡特兰数
- poj 2084 Game of Connections (卡特兰数,大数乘除)
- 深入剖析Windows XP的BOOT.INI
- 基序发现问题和中间字符串问题
- DNA序列剖面
- 限制酶切算法
- 2010年寄语
- POJ 2084 Game of Connections
- 2009最后回忆
- 检测DNA
- 遗传信息流
- 男女之间互送礼物的含义大全 别送错了
- 以下为2009软件百强企业名单
- 虚拟化技术入门
- 圣诞节的巴黎
- 随机验证码------WEB开发(登录提交 或避免重复提交数据)常用