hdu-1130(卡特兰数+大数乘法,除法模板)
题目链接: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(卡特兰数+大数乘法,除法模板)的更多相关文章
- HDU 1134 卡特兰数 大数乘法除法
Problem Description This is a small but ancient game. You are supposed to write down the numbers 1, ...
- 2014年百度之星程序设计大赛 - 初赛(第一轮) hdu Grids (卡特兰数 大数除法取余 扩展gcd)
题目链接 分析:打表以后就能发现时卡特兰数, 但是有除法取余. f[i] = f[i-1]*(4*i - 2)/(i+1); 看了一下网上的题解,照着题解写了下面的代码,不过还是不明白,为什么用扩展g ...
- hdu 1130,hdu 1131(卡特兰数,大数)
How Many Trees? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1134 Game of Connections(卡特兰数+大数模板)
题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 20 ...
- (母函数 Catalan数 大数乘法 大数除法) Train Problem II hdu1023
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...
- Buy the Ticket HDU 1133 卡特兰数应用+Java大数
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...
- 【hdoj_1133】Buy the Ticket(卡特兰数+大数)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目的意思是,m个人只有50元钱,n个人只有100元整钱,票价50元/人.现在售票厅没钱,只有50元 ...
- HDU-4828 卡特兰数+带模除法
题意:给定2行n列的长方形,然后把1—2*n的数字填进方格内,保证每一行,每一列都是递增序列,求有几种放置方法,对1000000007取余: 思路:本来想用组合数找规律,但是找不出来,搜题解是卡特兰数 ...
随机推荐
- XE 安装后C盘占用太大,C盘空间清理
XE安装完C盘可以清理的垃圾缓存文件 C:\ProgramData\{0DE47792-19BD-4AF4-B9CF-6378FBA44825} XE6 9个G,xe7 18G XE6如此,XE7安 ...
- MySQLNonTransientConnectionException
将mysql-connector-java和druid升级到最新版本: 将驱动设置为driver-class-name: com.mysql.cj.jdbc.Driver url要加上时区设置:url ...
- Mysql 主- 开启binlog
https://www.cnblogs.com/martinzhang/p/3454358.html my.cnf 添加 log_bin=mysql-bin 开启日志,然后重启mysql服务器. 查看 ...
- ServiceLoader实现原理
在java中根据一个子类获取其父类或接口信息非常方便,但是根据一个接口获取该接口的所有实现类却没那么容易. 有一种比较笨的办法就是扫描classpath所有的class与jar包中的class,然后用 ...
- playbook相关
ansible-playbook site.yml -f 10 ansible-playbook常用参数说明: -f 10 启用10个并发进程数执行playbook -u RM ...
- Linux_free(buffer与cache区别)
一.free命令[root@xen_202_12 /]# free -m total used free shared buffers ...
- servlet类第二篇
1servlet的生命周期是什么? 服务器启动时(web.xml中配置load-on-startup=1,默认为0)或者第一次请求该servlet时,就会初始化一个Servlet对象,也就是会执行初始 ...
- 实现溢出文本eclipsis的解决
实现溢出文本eclipsis的解决:overflow:hidden;text-overflow:ellipsis; white-space:nowrap; 如:<a href="&qu ...
- 疯狂JAVA——第五章 面向对象(上)
5.1类和对象 构造器是一个类创建对象的根本途径,如果一个类没有构造器,这个类通常无法创建实例.通过new关键字来调用构造器,从而返回该类的实例. 类名:每个单词首字母大写,其他字母小写,单词之间不要 ...
- Error: Cannot find a valid baseurl for repo: epel
修改一下/etc/yum.repos.d/epel.repo文件, enable=1改为enable=0