当前位置:网站首页>【集训Day2】cinema ticket
【集训Day2】cinema ticket
2022-07-26 16:55:00 【SSL_GYX】
cinema ticket

解题思路
易得递推式为 f i , j = f i − 1 , j + f i , j − 1 f_{i,j}=f_{i-1,j}+f_{i,j-1} fi,j=fi−1,j+fi,j−1 。
已知当 i = = j i==j i==j , f i , j f_{i,j} fi,j 为卡特兰数的第 i i i 项。
可以推得 a n s = ( n + 1 − m ) ( n + m ) ! m ! ( n + 1 ) ! ans=\frac{(n+1-m)(n+m)!}{m!(n+1)!} ans=m!(n+1)!(n+1−m)(n+m)! 。
需要高精度。
code
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
struct num{
int s[10010];
num operator *(int x)
{
num t={
0};
int lst=0;
for(int i=10000;i;i--)
{
t.s[i]=s[i]*x+lst;
lst=t.s[i]/10;
t.s[i]%=10;
}
return t;
}
num operator /(int x)
{
num t={
0};
int lst=0;
for(int i=1;i<=10000;i++)
lst=lst*10+s[i],t.s[i]=lst/x,lst%=x;
return t;
}
num operator -(num x)
{
num t={
0};
for(int i=10000;i;i--)
{
if(s[i]>=x.s[i])
t.s[i]=s[i]-x.s[i];
else
t.s[i]=s[i]+10-x.s[i],s[i-1]--;
}
return t;
}
}a,b;
int main()
{
cin>>n>>m;
int i,j;
b.s[10000]=1;
for(i=1,j=n+m;i<m;i++,j--)
b=b*j,b=b/i;
a=b*j,a=a/i;
num ans=a-b;
i=0;
while(!ans.s[i]) i++;
while(i<=10000) cout<<ans.s[i++];
}
边栏推荐
- 常用超好用正则表达式!
- Spark统一内存划分
- 简述CUDA镜像构建
- Gan (generative adversarial network, GaN) generative countermeasure network
- What kind of product is the Jetson nano? (how about the performance of Jetson nano)
- kaggle猫狗数据集开源——用于经典CNN分类实战
- Application of machine vision in service robot
- 来吧开发者!不只为了 20 万奖金,试试用最好的“积木”来一场头脑风暴吧!...
- 2022 年有哪些流行的技术?
- Come on developer! Not only for the 200000 bonus, try the best "building blocks" for a brainstorming
猜你喜欢

COSCon'22城市/学校/机构出品人征集令

树形dp问题

# MySQL 七种连接方式图解

About the adjustment of the game background, reading this article is enough

带你熟悉云网络的“电话簿”:DNS
![[C language classic topic exercise 2]](/img/66/8dbfefe585aa35f5791f04b376b75c.png)
[C language classic topic exercise 2]

(24) the top menu of blender source code analysis shows code analysis

Kudu design tablet

JS 递归 斐波那契数列 深克隆

【元宇宙欧米说】剖析 Web3 风险挑战,构筑 Web3 生态安全
随机推荐
In depth exploration of ribbon load balancing
Ascend target detection and recognition - customize your own AI application
Oracle is slow to perform a large number of DML operations. Is it the problem of CPU or hard disk?
Pytest(思维导图)
ASEMI整流桥KBPC3510,KBPC3510封装,KBPC3510应用
[virtual machine data recovery] data recovery cases in which XenServer virtual machine is unavailable due to accidental power failure and virtual disk files are lost
VS Code 格式化后 自动让函数名后有空格
国际大咖 VS 本土开源新星 | ApacheCon Asia 主题演讲议程全览
PIP installation module, error
Detailed explanation of openwrt's feeds.conf.default
236. 二叉树的最近公共祖先
【OpenCV 例程 300篇】240. OpenCV 中的 Shi-Tomas 角点检测
How to write plug-ins quickly with elisp
JS 闭包 模拟私有变量 面试题 立即执行函数IIFE
The principle of reliable transmission in TCP protocol
【云原生】 iVX 低代码开发 引入腾讯地图并在线预览
Asemi rectifier bridge kbpc3510, kbpc3510 package, kbpc3510 application
Centos安装docker以及mysql和redis环境
Pay attention to the traffic safety warning of tourism passenger transport issued by the Ministry of public security
[machine learning] principle and code of mean shift