题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1130

卡特兰数:https://blog.csdn.net/qq_33266889/article/details/53409553

参考文章:https://blog.csdn.net/sunshine_YG/article/details/47685737

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int base = ;
const int maxn = ;
int a[maxn+][maxn+],n,i,j;
void Init()
{
int tmp;
a[][]=;a[][]=;a[][]=;
for(i=;i<=;i++)
{
for(j=;j<;j++)
{
a[i][j]+=a[i-][j]*(*i-);
a[i][j+]+=a[i][j]/base;
a[i][j]%=base;
}
for(j=;j>=;j--)
{
tmp=a[i][j]%(i+);
a[i][j-]+=tmp*base;
a[i][j]/=(i+);
}
}
}
int main(void)
{
Init();
while(~scanf("%d",&n))
{
i=;
while(a[n][i]==) i--;
printf("%d",a[n][i--]);
while(i>) printf("%04d",a[n][i--]);
printf("\n");
}
return ;
}

hdu-1130(卡特兰数+大数乘法,除法模板)的更多相关文章

  1. HDU 1134 卡特兰数 大数乘法除法

    Problem Description This is a small but ancient game. You are supposed to write down the numbers 1, ...

  2. 2014年百度之星程序设计大赛 - 初赛(第一轮) hdu Grids (卡特兰数 大数除法取余 扩展gcd)

    题目链接 分析:打表以后就能发现时卡特兰数, 但是有除法取余. f[i] = f[i-1]*(4*i - 2)/(i+1); 看了一下网上的题解,照着题解写了下面的代码,不过还是不明白,为什么用扩展g ...

  3. hdu 1130,hdu 1131(卡特兰数,大数)

    How Many Trees? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  4. HDU 1134 Game of Connections(卡特兰数+大数模板)

    题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 20 ...

  5. (母函数 Catalan数 大数乘法 大数除法) Train Problem II hdu1023

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)

    Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...

  7. Buy the Ticket HDU 1133 卡特兰数应用+Java大数

    Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...

  8. 【hdoj_1133】Buy the Ticket(卡特兰数+大数)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目的意思是,m个人只有50元钱,n个人只有100元整钱,票价50元/人.现在售票厅没钱,只有50元 ...

  9. HDU-4828 卡特兰数+带模除法

    题意:给定2行n列的长方形,然后把1—2*n的数字填进方格内,保证每一行,每一列都是递增序列,求有几种放置方法,对1000000007取余: 思路:本来想用组合数找规律,但是找不出来,搜题解是卡特兰数 ...

随机推荐

  1. AS3中String转换成Boolean

    AS3中, 对布尔值的转换, 规定所有的非空字符串都是true. 下面都不行: var f:Boolean = new Boolean(str); var f:Boolean = str as Boo ...

  2. UI5-文档-导航栏

    UI5-文档-1-前言 UI5-文档-2-开发环境 UI5-文档-2.1-使用OpenUI5开发应用 UI5-文档-2.2-使用SAP Web IDE开发应用程序 UI5-文档-2.3-使用SAPUI ...

  3. 值得推荐的C/C++开源框架和库

    值得推荐的C/C++开源框架和库  转自:http://www.cnblogs.com/lidabo/p/5514155.html   - 1. Webbench Webbench是一个在Linux下 ...

  4. TEXT 8 Ready, fire, aim

    TEXT 8 Ready, fire, aim 预备!开火!瞄准!! Feb 16th 2006 From The Economist print edition Foreword:A vice-pr ...

  5. Scala语言学习笔记(2)

    表达式,值,变量,代码块,函数,方法 // 表达式 1 + 1 println(1 + 1) // 2 // 值(values)使用 val 关键字声明,带初值时类型可省略. val x = 1 + ...

  6. JDK5并发(2) Locks-ReentrantLock

    Java.concurrent.locks(2)-ReentrantLock @(Base)[JDK, locks, ReentrantLock, AbstractQueuedSynchronizer ...

  7. hadoop 集群安装配置 【转】

    http://www.cnblogs.com/ejiyuan/p/5557061.html 注意:要把master 上所有的配置文件(主要是配置的那四个 xxxx-site.xml 和 xxx-env ...

  8. 机房servlet过滤器

    1.源代码 loginform.html <html> <head> <title>使用过滤器改变请求编码</title> <meta http- ...

  9. bash: ifconfig: command not found 问题解决

    ifconfig使用出现问题了?竟然提示找不到~~于是百度~~ [flymouse@localhost /]$ ifconfig 提示:“bash: ifconfig: command not fou ...

  10. Docker三剑客之 Compose

    简介 Docker-Compose 是 Docker 的一种编排服务,是一个用于在 Docker 上定义并运行复杂应用的工具,可以让用户在集群中部署分布式应用. 通过 Docker-Compose 用 ...