当前位置:网站首页>The concept and application of Cartland number
The concept and application of Cartland number
2022-07-02 01:06:00 【Alkali!】
Concept
C n 2 n − C n − 1 2 n = C n 2 n n + 1 C_{n}^{2n}-C_{n-1}^{2n}=\frac{C_{n}^{2n}}{n+1} Cn2n−Cn−12n=n+1Cn2n
Application 1
Background

Their thinking
take 01 The sequence is placed in the coordinate system , The starting point is set at the origin . if 0 To the right ,1 To go up , So in any prefix 0 No less than 1 The number of is transformed into , Any point on the path , The abscissa is greater than or equal to the ordinate . The problem is the number of such legal paths .
The following figure , From (0,0) Go to the (n,n) The path of , The green line and below indicate legal , It is illegal to touch the red line .
It can be seen from the picture that , Any illegal path ( Such as black path ), All correspond to one from (0,0) Go to the (n−1,n+1) A path for ( Such as gray path ). And any one (0,0) Go to the (n−1,n+1) The path of , It also corresponds to one from (0,0) Go to the (n,n) Illegal path .
The answer is shown in the figure , The Cartland number .
Template code
// Background :AcWing 889
#include<iostream>
using namespace std;
const int N=100010,mod=1e9+7;
typedef long long LL;
int a,b,n;
int qmi(int a,int b,int p)
{
int res=1;
while(b)
{
if(b&1) res=(LL)res*a%mod;
a=(LL)a*a%mod;
b=b>>1;
}
return res;
}
int main()
{
scanf("%d",&n);
a=2*n,b=n;
int res=1;
for(int i=a;i>a-b;i--) res=(LL)res*i%mod;
for(int i=1;i<=b;i++) res=(LL)res*qmi(i,mod-2,mod)%mod;
// Convert division to modular inverse of multiplication
res=(LL)res*qmi(n+1,mod-2,mod)%mod;
printf("%d",res);
return 0;
}
边栏推荐
- Bc35 & bc95 onenet mqtt (old)
- ACM tutorial - quick sort (regular + tail recursion + random benchmark)
- SSO single sign on implementation.
- 449-原码、补码、反码
- How does schedulerx help users solve the problem of distributed task scheduling?
- Global and Chinese market of picture archiving and communication system (PACS) 2022-2028: Research Report on technology, participants, trends, market size and share
- AIX存储管理之逻辑卷的创建及属性的查看和修改
- excel查找与引用函数
- Output results of convolution operation with multiple tensors and multiple convolution kernels
- Powerful calendar wechat applet source code - support the main mode of doing more traffic
猜你喜欢

Excel search and reference function

969 interlaced string

Tensorflow tensor convolution, input and convolution kernel dimension understanding

SSO single sign on implementation.
![[leetcode] number of maximum consecutive ones](/img/70/7f3d1c8e0ab2698d98220cca911209.png)
[leetcode] number of maximum consecutive ones

Leetcode skimming: stack and queue 06 (top k high-frequency elements)

Develop a simple login logic based on SSM

Excel PivotTable

Leetcode question brushing: stack and queue 07 (maximum value of sliding window)

Collection: comprehensive summary of storage knowledge
随机推荐
Random avatar encyclopedia, multi category wechat applet source code with history_ Support traffic master
You probably haven't noticed the very important testing strategy in your work
Node -- egg implements the interface of uploading files
Evolution of Himalayan self-developed gateway architecture
The pain of Xiao Sha
Recently, three articles in the nature sub Journal of protein and its omics knowledge map have solved the core problems of biology
gradle
How to type spaces in latex
AIX存储管理之逻辑卷的创建及属性的查看和修改
Summary of Aix storage management
The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
【八大排序③】快速排序(动图演绎Hoare法、挖坑法、前后指针法)
2023款雷克萨斯ES产品公布,这回进步很有感
Leetcode skimming: stack and queue 01 (realizing queue with stack)
JMeter做接口测试,如何提取登录Cookie
Creating logical volumes and viewing and modifying attributes for AIX storage management
Source code of Qiwei automatic card issuing system
AIX存储管理之总结篇
Node -- egg creates a local file access interface
【八大排序①】插入排序(直接插入排序、希尔排序)