HDU——1134 Game of Connections
Game of Connections
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4844 Accepted Submission(s): 2811
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?
3
-1
5
#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");
}
;
}
HDU——1134 Game of Connections的更多相关文章
- HDU 1134 Game of Connections(卡特兰数+大数模板)
题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 20 ...
- hdu 1134 Game of Connections
主要考察卡特兰数,大数乘法,除法…… 链接http://acm.hdu.edu.cn/showproblem.php?pid=1134 #include<iostream>#include ...
- HDU - 1134 Game of Connections 【DP】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1134 题意 给出一个n 然后有2n个点 给两个点连一条边,最后连N条边,要求所有的边不能够交叉 问最多 ...
- HDU ACM 1134 Game of Connections / 1130 How Many Trees?(卡特兰数)
[题目链接]http://acm.hdu.edu.cn/showproblem.php?pid=1134 [解题背景]这题不会做,自己推公式推了一段时间,将n=3和n=4的情况列出来了,只发现第n项与 ...
- 【HDOJ】1134 Game of Connections
Catlan数. /* 1134 */ import java.util.Scanner; import java.math.BigInteger; /* Catalan: (1) h(n) = h( ...
- HDU 1134 卡特兰数 大数乘法除法
Problem Description This is a small but ancient game. You are supposed to write down the numbers 1, ...
- ACM第一阶段学习内容
一.知识目录 字符串处理 ................................................................. 3 1.KMP 算法 .......... ...
- hdu 2874 Connections between cities [LCA] (lca->rmq)
Connections between cities Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- HDU 2874 Connections between cities (LCA)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2874 题意是给你n个点,m条边(无向),q个询问.接下来m行,每行两个点一个边权,而且这个图不能有环路 ...
随机推荐
- DFS BestCoder Round #49 ($) 1001 Untitled
题目传送门 /* DFS:从大到小取模,因为对比自己大的数取模没意义,可以剪枝.但是我从小到大也过了,可能没啥大数据 */ /************************************* ...
- Elasticsearch--扩展索引结构
目录 索引树形数据 索引非扁平数据 索引关系型数据 使用嵌套对象 评分与嵌套查询 使用主从关系 索引树形数据 使用path_analyzer分析树形数据字段 索引非扁平数据 数据如下: { " ...
- React 篇 Search Bar and content Table
我们要构建一个模块,其中包含一个内容显示的表格,然后上面有一个提供Search的栏位,并对Search中输入栏进行监听,当有改变的时候,触发Search然后对内容表中的内容进行过滤. Demo Lin ...
- Java运行报错问题——Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
http://blog.csdn.net/xifeijian/article/details/8830933 上述这个朋友博文提醒,可能是因为其他软件添加了JAVA_HOME的路径造成冲突.但他支持删 ...
- RabbitMQ调用
添加 gradle依赖complie("com.rabbitmq:amqp-client:5.0.0") Hello, World Working Queues Publish/S ...
- Codeforces_765_D. Artsem and Saunders_(数学)
D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input stand ...
- POJ_2387_最短路
Til the Cows Come Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 46859 Accepted ...
- 梦想MxWeb3D协同设计平台 2019.02.28更新
梦想MxWeb3D协同设计平台 2019.02.28更新 SDK开发包下载地址: http://www.mxdraw.com/ndetail_10130.html 在线演示网址: http://www ...
- ThinkPHP---插件highcharts
[一]概论 (1)介绍 基于jquery开发的国外图标插件,统计图,折线图,饼状图等常常用到. 国内也有一款类似插件echarts,由百度开发. (2)官网:www.highcharts.com ...
- 16Log4J
Log4J Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件.甚至是套接口服务器.NT的事件记录器.UNIX Syslog守 ...