博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7_7_2013 D.Brackets
阅读量:6948 次
发布时间:2019-06-27

本文共 1198 字,大约阅读时间需要 3 分钟。

hot3.png

Problem D: Brackets

Time Limit: 1 Sec  
Memory Limit: 32 MB
Submit: 70  
Solved: 23
[ ][ ][ ]

Description

This year MK is 5 years old. So he decides to learn some arithmetic. But he was confused by how to write the brackets. He has already known that the brackets should match when writing them correctly. Such as ()(()) is correct but ())( is not.

The problem is that, if there are N pairs of brackets, how many ways that MK can write them correctly? 

Input

There are several test cases. Each case contains a number N (1 <= N <= 1000) indicating the pairs of brackets.

Output

For each case, please output the answer mod 1,000,000,007.

Sample Input

5 7

Sample Output

42 429
#include 
#include
#define NUM 1000000007using namespace std;long long int a[1010];intmain(){ int n; a[0]=1; for(int i = 1; i <= 1000; i++) { for(int j = 0; j < i; j++) { a[i]=a[i]+a[j]*a[i-j-1]%NUM; a[i]=a[i]%NUM; } } //cout<
<
<
<
<
<
<
<
>n){ cout<
<
說好的

卡特兰数

just 坑爹 比賽的時候用的h(n)=h(n-1)*(4*n-2)/(n+1);這個遞推公式,這個是不適合大數取模運算的

转载于:https://my.oschina.net/dianpaopao/blog/143329

你可能感兴趣的文章
从ASM迁移到ARM(1):平台支持的迁移服务
查看>>
扩展jQuery easyui datagrid增加动态改变列编辑的类型
查看>>
通过Linux shell实现的花生壳动态域名解析(DDNS)
查看>>
Mysql 生成按月份统计SQL语句,为null设置为0
查看>>
驰骋工作流程引擎回答湖南朋友的21个问题
查看>>
使用htmlPurifier 过滤输入能不能不要把&转义成&
查看>>
6、OC —— 内存管理基本概念
查看>>
在多台linux主机上执行相同的命令
查看>>
1.6的锁优化(适应性自旋/锁粗化/锁削除/轻量级锁/偏向锁)
查看>>
C/C++源码网站
查看>>
SICP 2.40 2.41 2.42 2.43
查看>>
建立cover组 成员有cover01 cover02 建立team组 成员有team 01 team02 建立user组 成员有user...
查看>>
linux pxe 系统自动化安装
查看>>
iOS游戏开发有奖征文
查看>>
控制台读写
查看>>
LVS+keepalived负载均衡实战
查看>>
使用 IntraWeb (17) - 基本控件之 TIWRadioButton、TIWRadioGroup、TIWCheckBox
查看>>
KVM虚拟化搭建及其KVM中LVM扩容
查看>>
管理磁盘和文件系统
查看>>
CSS解决高度自适应问题
查看>>