当前位置:网站首页>[training Day2] cinema ticket [combinatorics] [Cartland number]
[training Day2] cinema ticket [combinatorics] [Cartland number]
2022-07-18 15:50:00 【VL——MOESR】

Ideas :
First, recursive , Find out
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
among i>=j
So we found i==j Time is Cartland number , Then we can push the inner layer step by step
Finally, the simplified formula is ( n + 1 − m ) ∗ ( m + n ) ! ( m ! ∗ ( n + 1 ) ! ) \frac{(n+1-m)*(m+n)!}{(m!*(n+1)!)} (m!∗(n+1)!)(n+1−m)∗(m+n)!
( I'm going to melt myself , A little bit of a problem )
c o d e code code
#include<iostream>
#include<cstdio>
using namespace std;
int n, m, maxx;
int a[10010], b[10010], c[10001];
void fenj(int x)
{
int j=2;
while(x!=1)
{
while(x%j==0)
{
x/=j;
a[j]++;
}
j++;
}
if(x!=1)
a[x]++;
}
void fenk(int x)
{
int j=2;
while(x!=1)
{
while(x%j==0)
{
x/=j;
b[j]++;
}
j++;
}
if(x!=1)
b[x]++;
}
void cheng(int x)
{
int g=0;
for(int i=10000; i>=1; i--)
{
c[i]=c[i]*x+g;
g=c[i]/10;
c[i]%=10;
}
}
void write_()
{
int i=1;
while(c[i]==0) i++;
while(i<=10000) printf("%d", c[i]), i++;
}
int main()
{
scanf("%d%d", &n, &m);
fenj(n+1-m);
for(int i=1; i<=n+m; i++)
fenj(i);
for(int i=1; i<=m; i++)
fenk(i);
for(int i=1; i<=n+1; i++)
fenk(i);
for(int i=1; i<=10000; i++)
a[i]-=b[i];
for(int i=10000; i>=1; i--)
if(a[i])
{
maxx=i;
break;
}
c[10000]=1;
for(int i=1; i<=maxx; i++)
while(a[i]) a[i]--, cheng(i);
write_();
return 0;
}
边栏推荐
猜你喜欢

cv2.setMouseCallback()显示鼠标点击图片的像素值和位置

CV2. Setmousecallback() displays the pixel value and position of the mouse click image

iowait 理解

Well known to do apps at home and abroad

mysql与idea建立连接出错

Runtime data area & method area (permanent generation / meta space) & stack frame

基于时间戳的唯一标识符的轻量级跟踪方法

Can SQL also do AI? you 're right! Mlops meetup V3 review openmlbd+sqlflow+byzer

怎么设置域名解析?

Compilation optimization from the release of Xiaomi 10
随机推荐
leetcode:378. The k-th smallest element in an ordered matrix
ESRI launches indoor positioning system for facility routing
HMS core graphics and image technology shows the latest functions and application scenarios, and accelerates the construction of digital intelligence life
高性能定时器
Detailed explanation of the decision table method of common test case design methods
PostgreSQL 现在安装
如何用断言思路优雅地处理代码异常
Cron expressions are executed from Monday to Friday and only on Saturday and Sunday
Domestic postman tool, easy to use!
使用arcpy遇到的那些坑(三)
在okcc中你了解呼叫并发的含义吗?
[prefix and difference]
leetcode:378. 有序矩阵中第 K 小的元素
剑指offer 46:把数字翻译成字符串
cv2.setMouseCallback()显示鼠标点击图片的像素值和位置
AcWing 133. 蚯蚓
1111111111111
新功能上线需要发版本,回归测试中总是出现之前没有的问题
Code to celebrate the Dragon Boat Festival -- Zong your heart
cron 表达式周一到周五执行以及只有周六周天执行