Train Problem II HDU 1023 卡特兰数
The result will be very large, so you may not process it by 32-bit integers.
出栈次序
#include<iostream>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<fstream>
#include<memory>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAXN 102
#define INF 1000000009
/*
给定递增顺序进入,问有多少种方式出栈
1 1
2: 1-2 2-1
3: 123
*/
int a[MAXN][MAXN];
void init()
{
int i, j, yu, len;
a[][] = ; a[][] = ;
a[][] = ; a[][] = ;
len = ;
for (i = ; i < MAXN; i++)
{
yu = ;
for (j = ; j <= len; j++)
{
int tmp = a[i - ][j] * ( * i - ) + yu;
yu = tmp / ;
a[i][j] = tmp % ;
}
while (yu)
{
a[i][++len] = yu % ;
yu /= ;
}
for (j = len; j > ; j--)
{
int tmp = a[i][j] + yu*;
a[i][j] = tmp / (i + );
yu = tmp % (i + );
}
while (!a[i][len])
len--;
a[i][] = len;
}
}
int main()
{
init();
int n;
while (scanf("%d", &n) != EOF)
{
for (int i = a[n][]; i > ; i--)
printf("%d", a[n][i]);
printf("\n");
}
}
Train Problem II HDU 1023 卡特兰数的更多相关文章
- HDU 1023 Train Problem II (大数卡特兰数)
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1023 卡特兰数+高精度
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1023 卡特兰数《 大数》java
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1023 Train Problem II( 大数卡特兰 )
链接:传送门 题意:裸卡特兰数,但是必须用大数做 balabala:上交高精度模板题,增加一下熟悉度 /************************************************ ...
- HDU 1023(卡特兰数 数学)
题意是求一列连续升序的数经过一个栈之后能变成的不同顺序的数目. 开始时依然摸不着头脑,借鉴了别人的博客之后,才知道这是卡特兰数,卡特兰数的计算公式是:a( n ) = ( ( 4*n-2 ) / ...
- Train Problem II(卡特兰数 组合数学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023 Train Problem II Time Limit: 2000/1000 MS (Java/ ...
- hdu 1023 Train Problem II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- Train Problem II(卡特兰数+大数乘除)
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- codevs2147数星星(哈希)
2147 数星星 时间限制: 3 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond 题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘 ...
- thinkphp自带的验证码出现的问题
thinkphp3.1.2版本中今天做验证码时出现了一个小问题. 在后台我引入过了一次验证也就是 import('ORG.Util.Image'); Image::buildImageVerify() ...
- [Swift通天遁地]八、媒体与动画-(14)使用TextKit快速实现文章的分栏效果
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- 面向对象之继承-5种JavaScript继承的方法
今天我们讨论一下常用的几种继承方法:首先我们创建一个动物函数Animal: function Animal () { this.species = '动物' }再写准备名叫猫咪的函数Cat: func ...
- 【洛谷2257/BZOJ2820】YY的GCD(数论/莫比乌斯函数)
题目: 洛谷2257 预备知识:莫比乌斯定理(懵逼乌斯定理) \(\mu*1=\epsilon\)(证bu明hui略zheng) 其中(我校学长把\(\epsilon(x)\)叫单位函数但是为什么我没 ...
- 【原】cocos2d-x开发笔记:获取Sprite上某一个点的透明度,制作不规则按钮
本篇文章主要讲一下怎么做一个不规则的按钮,比如如下图的八卦,点击绿色和点击红色部分,需要执行不同的事件
- easyui datagrid 高度布局自适应
最近在把以前写的一个项目改成用easyui做前端.过程中遇到了不少问题.其中一个就是datagrid不能很好的布局.想了好多办法都有局限.最后想到会不会是布局(easyui-layout)的问题,经过 ...
- vs项目结构解析
当我们用VS开发一个项目的时候,首先应该清楚用VS这个IDE生成的一些文件和文件夹是什么意思,起什么作用,什么场合下使用. 因为我使用的是VS2015,就以这个为例来进行一些说明: 首先要做的是更改你 ...
- python 根据数组生成图片
array = np.asarray(allBigPng, dtype=np.uint8)image = Image.fromarray(array, 'RGBA') image.save(outpu ...
- [转]Wote用python语言写的imgHash.py
#!/usr/bin/python import glob import os import sys from PIL import Image EXTS = 'jpg', 'jpeg', 'JPG' ...
