题目链接_HDU-1023

题目

As we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders that all the trains can get out of the railway.

input

The input contains several test cases. Each test cases consists of a number N(1<=N<=100). The input is terminated by the end of file.

output

For each test case, you should output how many ways that all the trains can get out of the railway.

Sample Input

1

2

3

10

Sample Output

1

2

5

16796

思路:

仔细一看,就是让你求卡特兰数,只不过这个数的范围大了点,会爆long long ,所以要用数组来进行存储。这道题的核心应该就是让求大数对一个较小的数的乘法和除法。

而这个乘法和除法(因为是对一个较小的数的操作)所以就是简单的模拟我们平常手算对数的乘法和除法。

具体代码实现如下:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[2005];
void mu(int k)
{
int c=0;
for(int i=1;i<=2000;i++)
{
int u=a[i]*k+c;
a[i]=u%10;
c=u/10;
} }
void chu(int k)
{
int c=0;
for(int i=2000;i>=1;i--)
{
int u=a[i]+c;
a[i]=u/k;
c=u%k*10;
}
}
int main()
{
int n;
while(~scanf("%d",&n))
{
memset(a,0,sizeof(a));
a[1]=1;
for(int i=n+1;i<=2*n;i++)
{
mu(i);
}
for(int i=1;i<=n+1;i++)
{
chu(i);
}
int flog=0;
for(int i=2000;i>=1;i--)
{
if(a[i]!=0)
{
flog=1;
}
if(flog==1)
{
printf("%d",a[i]);
}
}
printf("\n");
}
return 0;
}

C - Train Problem II——卡特兰数的更多相关文章

  1. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  2. HDU-1023 Train Problem II 卡特兰数(结合高精度乘除)

    题目链接:https://cn.vjudge.net/problem/HDU-1023 题意 卡特兰数的应用之一 求一个长度为n的序列通过栈后的结果序列有几种 思路 一开始不知道什么是卡特兰数,猜测是 ...

  3. HDU 1023 Train Problem II (卡特兰数,经典)

    题意: 给出一个数字n,假设火车从1~n的顺序分别进站,求有多少种出站序列. 思路: 卡特兰数的经典例子.n<101,用递推式解决.需要使用到大数.n=100时大概有200位以下. #inclu ...

  4. HDOJ 1023 Train Problem II 卡特兰数

    火车进站出站的问题满足卡特兰数...卡特兰数的相关知识如下: 卡特兰数又称卡塔兰数,是组合数学中一个常出现在各种计数问题中出现的数列.由以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)命名. ...

  5. Train Problem II(卡特兰数+大数乘除)

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

  6. HDU 1023 Train Problem II (大数卡特兰数)

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

  7. Train Problem II(卡特兰数 组合数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023 Train Problem II Time Limit: 2000/1000 MS (Java/ ...

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

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

  9. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

随机推荐

  1. 伸缩容器-display:flex设置flex属性的理解

    1.flex属性 1.1 flex属性是flex-grow, flex-shrink 和 flex-basis的简写,默认值为0 1 auto. flex-grow: 定义项目的放大比例,默认为0,即 ...

  2. 【MyBatis】配置文件提示

    [MyBatis]配置文件提示 官方帮助文档:http://www.mybatis.org/mybatis-3/zh/index.html config配置 http://mybatis.org/dt ...

  3. textarea增加字数监听且高度自适应(兼容IE8)

    1.封装方法: var textareaListener = { /*事件监听器兼容 * *attachEvent——兼容:IE7.IE8:不兼容firefox.chrome.IE9.IE10.IE1 ...

  4. 关于HPS和FPGA之间的桥接学习笔记一

    为了实现FPGA和HPS之间的存储器共享和数据传输,Altera SoC FPGA提供了两种方式用于FPGA和HPS通信.分别是FPGA to SDRAM和AXI bridge. FPGA to SD ...

  5. Power Platform之Power Automate新增RPA功能

    ​ 什么是RPA RPA( Robotic Process Automation 机器人流程自动化软件),是一种新型的人工智能的虚拟流程自动化机器人.RPA的核心是通过自动化.智能化技术来“替代人”进 ...

  6. 《Java基础知识》Java继承的概念和实现

    继承时类和类之间的关系,是一个很简单很直观的概念,与显示生活中的继承(例如儿子继承了父亲财产)类似. 继承可以理解为一个类从另一个类中获取方法和属性的过程.如果类B继承于类A,那么类B就拥有类A的属性 ...

  7. Django3.0 异步通信初体验(小结)

    2019年12月2日,Django终于正式发布了3.0版本.怀着无比的期待,我们来尝试一下吧! (附ASGI官方文档地址:https://asgi.readthedocs.io/en/latest/e ...

  8. 实验:使用GDB查看结构体在内存中的存储方式

    结构体在内存中的表示形式是怎么样的? 结构体在内存中和普通变量存储没有太大的区别. 首先我们看看,计算机如何读取普通变量:   普通变量例如int是占据4个字节,计算机读内存的时候会从起始地址开始读, ...

  9. ReadWriteLock场景应用解析

    本人免费整理了Java高级资料,涵盖了Java.Redis.MongoDB.MySQL.Zookeeper.Spring Cloud.Dubbo高并发分布式等教程,一共30G,需要自己领取.传送门:h ...

  10. SpringCloud-服务注册与实现-Eureka创建服务提供者(附源码下载)

    场景 SpringCloud-服务注册与实现-Eureka创建服务注册中心(附源码下载): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...