poj——2084 Game of Connections
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 8664 | Accepted: 4279 |
Description
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
You may assume that 1 <= n <= 100.
Output
Sample Input
2 3 -1
Sample Output
2 5
Source
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 110
using namespace std;
int n,len,tmp,sum,b[N],a[N][N];
int read()
{
,f=; char ch=getchar();
; ch=getchar();}
+ch-'; ch=getchar();}
return x*f;
}
int catelan()
{
len=; a[][]=b[]=;
;i<;i++)
{
;j<len;j++)
a[i][j]=a[i-][j]*(i*-);
sum=;
;j<len;j++)
{
tmp=sum+a[i][j];
a[i][j]=tmp%;
sum=tmp/;
}
while(sum)
{
a[i][len++]=sum%;
sum/=;
}
;j>=;j--)
{
tmp=sum*+a[i][j];
a[i][j]=tmp/(i+);
sum=tmp%(i+);
}
])
--len;
b[i]=len;
}
}
int main()
{
catelan();
)
{
n=read();
) break;
;i>=;i--)
printf("%d",a[n][i]);
printf("\n");
}
;
}
poj——2084 Game of Connections的更多相关文章
- POJ 2084 Catalan数+高精度
POJ 2084 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:42 * ...
- POJ 2084 Game of Connections(卡特兰数)
卡特兰数源于组合数学,ACM中比较具体的使用例子有,1括号匹配的种数.2在栈中的自然数出栈的种数.3求多边形内三角形的个数.4,n个数围城圆圈,找不相交线段的个数.5给定n个数,求组成二叉树的种数…… ...
- POJ 2084 Game of Connections
卡特兰数. #include<stdio.h> #include<string.h> ; ; void mul(__int64 a[],int len,int b) { int ...
- (组合数学3.1.2.2)POJ 2084 Game of Connections(卡特兰数公示的实现)
package com.njupt.acm; import java.math.BigInteger; import java.util.Scanner; public class POJ_2084 ...
- POJ 2084 Game of Connections 卡特兰数
看了下大牛们的,原来这题是卡特兰数,顺便练练java.递归式子:h(0)=1,h(1)=1 h(n)= h(0)*h(n-1) + h(1)*h(n-2) + ... + h(n-1)h(0) ( ...
- POJ 2084 Catalan
Game of Connections Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8772 Accepted: 43 ...
- poj——2367 Genealogical tree
Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6025 Accepted: 3969 ...
- POJ 2084
第一题组合数学题.可以使用递推,设1与其他各数分别连边,假设N=3;若1-4,则圆分成两部分计数,此时可以利用乘法原理.(高精度) #include <cstdio> #include & ...
- Poj 2796 单调栈
关于单调栈的性质,和单调队列基本相同,只不过单调栈只使用数组的尾部, 类似于栈. Accepted Code: /******************************************* ...
随机推荐
- 2017杭电多校第六场1008 Kirinriki
传送门 Kirinriki Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- HTML基础2——综合案例3——创建考试报名表格
<html> <head> <title></title> </head> <body> <table width=&qu ...
- Flume中的flume-env.sh和log4j.properties配置调整建议(图文详解)
GC是内存的回收的意思. Flume中的flume-env.sh配置调整建议 [hadoop@master conf_HostInterceptor]$ pwd /home/hadoop/app/fl ...
- Spring Boot (31) 数据验证
曾经参数的验证是这样的: public String test(User user){ if(user == null){ throw new NullPointerException("u ...
- C语言学习(1)-环境配置
写在前面的话,该文章是看杨老师的一套视频,所做的一些笔记,边看边写,再此谢谢杨老师. 1.学习C之前需要避免的误区 误区一:C++是C的升级版:C#是C++的升级版 误区二:C/C++就是Visual ...
- java excel poi导入 过滤空行的方法 判断是否是空行
private boolean isRowEmpty(Row row){ for (int c = row.getFirstCellNum(); c < row.getLastCellNum() ...
- HDU_6016_(Bestcoder round #92 1002)_(dfs)(暴力)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6016 题意:给定男羊和女羊的朋友关系,即给定一个图,问从任意一只羊开始连续数四只不相同的羊的方法数. ...
- 【转载】jQuery.extend 函数详解
转载自:http://www.cnblogs.com/RascallySnake/archive/2010/05/07/1729563.html jQuery.extend 函数详解 JQuery的e ...
- c++函数进阶
c++扩展了c语言的函数功能.通过将incline关键字用于函数定义,并在首次调用该函数前提供其函数定义,可以使得c++编译器将该函数视为内联函数.也就是说,编译器不是让程序跳到独立的代码段,以执行函 ...
- code blocks 安装与实践
背景 因为不是主要修习C/C++,仅用于写算法和数据结构,code blocks轻量但是安装老是出现问题,故有此记录 安装 官方地址:http://www.codeblocks.org/downloa ...