当前位置:网站首页>【集训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++];
}
边栏推荐
- Comparison between agile development and Devops
- 敏捷开发与DevOps的对比
- 办公软件常用快捷键大全
- 现在网上开户安全么?股票开户要找谁?
- 第17周自由入侵 指针练习--输出最大值
- 硬件开发与市场产业
- 就这一次!详细聊聊分布式系统的那些技术方案
- Just this time! Talk about the technical solutions of distributed system in detail
- Leetcode:1206. design jump table [jump table board]
- 得不偿失!博士骗领210万元、硕士骗领3万元人才补贴,全被判刑了!
猜你喜欢

Asemi rectifier bridge kbpc3510, kbpc3510 package, kbpc3510 application

Asemi rectifier bridge kbpc2510, kbpc2510 parameters, kbpc2510 specifications

How to set IP for layer 2 management switches

点击劫持攻击

ASEMI整流桥KBPC2510,KBPC2510参数,KBPC2510规格书

【模板】线段树 1

Kudu design tablet

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

Pytorch中的tensor操作

大咖访谈 | 开源对安全是双刃剑——《大教堂与集市》中文译本作者卫剑钒
随机推荐
In the first half of the year, sales increased by 10% against the trend. You can always trust Volvo, which is persistent and safe
API for sellers -- description of the return value of adding baby API to Taobao / tmall sellers' stores
2.1.2 同步始终失败
MySQL foundation - basic database operation
二层管理型交换机如何设置IP
Summer Challenge openharmony greedy snake based on JS
Is it safe to open an account online now? Who do you want to open a stock account?
uni-app
解决哈希冲突的几种方式
TD database syntax
Machine learning - what are machine learning, supervised learning, and unsupervised learning
JS 函数作用域 变量声明提升 作用域链 不加var的变量,是全局变量
On the growth of data technicians
大家下午好,请教一个问题:如何从保存点启动一个之前以SQL提交的作业?问题描述:用SQL在cl
Leetcode:1206. design jump table [jump table board]
浅谈数据技术人员的成长之路
Is it really safe and reliable to exempt five in case of opening an account in a stock company
6-19 vulnerability exploitation -nsf to obtain the target password file
COSCon'22城市/学校/机构出品人征集令
Why are test / development programmers who are better paid than me? Abandoned by the times