杭电ACM1134——Game of Connections
来源:互联网 发布:淘宝有哪些奇葩商品 编辑:程序博客网 时间:2024/05/16 17:41
卡特兰数的应用。
递推公式为:
h(n) = h(n - 1) * (4 * n - 1) / (n + 1).。
AC的代码:
#include <iostream>using namespace std;int data[102][100] = {0};void deal(){int i, j, k = 0;int temp[500];data[0][0] = 0;data[1][0] = 1;data[2][0] = 2;for(i = 3; i < 102; i++){for(j = 0; j < 100; j++){k += data[i - 1][j] * (4 * i - 2);temp[j] = k % 10;k /= 10;}for(j = 99; j >= 0; j--)if(temp[j])break;int div = 0;while(j >= 0){div = div * 10 + temp[j];temp[j] = div / (i + 1);div %= (i + 1);j--; }for(j = 0; j < 100; j++)data[i][j] = temp[j];}}int main(){deal();int n;while(cin >> n){if(n == -1)break;int j;for(j = 99; j >= 0; j--)if(data[n][j])break;cout << data[n][j--];while(j >= 0)printf("%d", data[n][j--]);cout << endl;}return 0;}
0 0
- 杭电ACM1134——Game of Connections
- POJ2084——Game of Connections
- POJ2084—Game of Connections(c++高精度)
- 1134 ---( Game of Connections )
- hdu1134-Game of Connections
- poj2084 Game of Connections
- Game of Connections
- acm-Game of Connections
- Game of Connections
- poj2084 Game of Connections
- HDU1134 Game of Connections
- Game of Connections
- WOJ1268-Game of Connections
- Game of Connections HDU
- Game of Connections HDU
- POJ 2084 Game of Connections
- HDOJ 1134: Game of Connections
- poj 2084 Game of Connections
- OpenJudge_P2988 计算字符串距离(DP)
- A星算法
- 二叉树的层序遍历
- 单词接龙
- 1002.写出这个数
- 杭电ACM1134——Game of Connections
- iOS:openURL
- 学习笔记 --- 线段树
- Android 图片压缩
- Sublime Text3 编译多个文件
- 网站提权
- 使用Visio画用例图没有include(包含)关系的解决办法
- ssh机器间添加信任关系
- Android开发 在AndoridStudio中引入GreenDAO