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行,每行两个点一个边权,而且这个图不能有环路 ...
随机推荐
- base64编码上传图片java后台接收实例
原文地址:http://blog.csdn.net/tonyfreak/article/details/72522855 思路 前台传以data:image/jpeg;base64,开头的base64 ...
- 利用 nodeJS 搭建一个简单的Web服务器(转)
下面的代码演示如何利用 nodeJS 搭建一个简单的Web服务器: 1. 文件 WebServer.js: //-------------------------------------------- ...
- 全面学习ORACLE Scheduler特性(11)使用Job Classes
六.使用Job Classes Job Classes 相当于创建了一个job组,DBA可以将那些具有相同特性的job,统统放到相同的Job Classes中,然后通过对Job Class应用ORAC ...
- cloudera-agent启动File not found : /usr/sbin/cmf-agent解决办法(图文详解)
不多说,直接上干货! 问题详情 bigdata@nssa-sensor1:~$ sudo service cloudera-scm-agent startFile not found : /usr/s ...
- Python学习日记之正则表达式re模块
用在线网页测试正则表达式时,JavaScript不支持 零宽度正回顾后发断言 (?<=exp)测试时一直匹配失败 但re模块是支持 (?<=exp) 的 终于脱坑
- Object.assign() 对象的扩展
object.assign()方法用于对象的合并,将源对象的(source)的所有的可枚举属性,复制到目标对象(target) var target = {a:1}; var source1={b:2 ...
- 可滚动的ResultSet类型 实现分页
可滚动的ResultSet类型. 这个类型支持前后滚动取得纪录next().previous(),回到第一行first(),同时还支持要取的 ResultSet中的第几行 absolute(int n ...
- (转)淘淘商城系列——Redis持久化方案
http://blog.csdn.net/yerenyuan_pku/article/details/72858975 Redis中设置key的过期时间 Redis中的expire命令用于设置key的 ...
- 安卓app测试之内存监控
一.通过Dumpsys 来取值 1.adb shell dumpsys meminfo 获取的所有进程的内存信息,以及总内存,剩余内存,使用的内存等信息. 2.想获得某一进程内存的详细信息,在后面加上 ...
- Shell printf命令
Shell 的另一个输出命令 printf.默认 printf 不会像 echo 自动添加换行符,我们可以手动添加 \n. #!/bin/bash printf "%-10s %-8s %- ...