HDU——1023 Train Problem II
Train Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9701 Accepted Submission(s): 5210
2
3
10
2
5
16796
The result will be very large, so you may not process it by 32-bit integers.
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define N 110
using namespace std;
int n,len,sum,tmp,a[N][N],b[N];
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();
while(~scanf("%d",&n))
{
;i>=;i--)
printf("%d",a[n][i]);
printf("\n");
}
}
HDU——1023 Train Problem II的更多相关文章
- hdu 1023 Train Problem II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...
- HDU 1023 Train Problem II (大数卡特兰数)
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Train Problem II(卡特兰数 组合数学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023 Train Problem II Time Limit: 2000/1000 MS (Java/ ...
- 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) ...
- (母函数 Catalan数 大数乘法 大数除法) Train Problem II hdu1023
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)
数字的反转: 就是将数字倒着存下来而已.(*^__^*) 嘻嘻…… 大致思路:将数字一位一位取出来,存在一个数组里面,然后再将其变成数字,输出. 详见代码. while (a) //将每位数字取出来, ...
- Train Problem II HDU 1023 卡特兰数
Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...
- 1023 Train Problem II(卡特兰数)
Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...
随机推荐
- spring Cache /Redis 缓存 + Spring 的集成示例
spring Cache https://www.ibm.com/developerworks/cn/opensource/os-cn-spring-cache/ spring+redis 缓存 ht ...
- [BZOJ:3162]:独钓寒江雪
题解: 求本质不同的独立集的个数 首先独立集的个数是很好做的 \(f[u][0/1]\)表示节点\(u\)不选/选的方案数 然后dp就是 \(f[u][0] = f[u][0] * (f[v][0] ...
- lower_bound和upper_bound函数
lower_bound(ForwardIter first,ForwardIter last,const_TP & val) upper_bound(ForwardIter first,For ...
- 水题 CodeForces 137A Postcards and photos
题目传送门 /* 水! */ #include <cstdio> #include <cstring> #include <algorithm> using nam ...
- 6.12---bug
- Python学习日记之文件读取操作
Python内置了文件读写的函数open,read 用法示例: open('/home/root/files.txt ') 在打开文件后,操作完成后可以使用close()关闭文件,但比较好的文件读写方 ...
- css的新特性 calc () 使用
calc()对大家来说,或许很陌生,不太会相信calc()是css中的部分.因为看其外表像个函数,既然是函数为何又出现在CSS中呢?这一点也让我百思不得其解,今天有一同事告诉我,说CSS3中有一个属性 ...
- 328.io流(字符串-练习-复制文本文件一)
public static void main(String[] args) { // TODO Auto-generated method stub FileReader fr = null; Fi ...
- Win7 下 PB (PowerBuilder) Insert Control 崩溃的解决办法
环境: WIN7 x86 PB8.0, x64系统目录不同,不过也可以试试 Insert -> OLE... -> Insert Control - 崩溃 如果网上提供的办法解决不了你 ...
- VS2015 安装包缺失(联网安装失败)问题解决
Win7 x86 测试可行 * 如果前面有尝试过安装不成功, 一定要用卸载程序删除已安装的部分,否则会出乱子. 1. 或者是用虚拟光驱加载ISO, 或者是解压到硬盘上, 都没有关系. 2. 用管理员 ...