当前位置:网站首页>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;
}
边栏推荐
- 测试员8年工资变动,令网友羡慕不已:你一个月顶我一年工资
- Leetcode skimming: stack and queue 05 (inverse Polish expression evaluation)
- Global and Chinese market of wireless charging magnetic discs 2022-2028: Research Report on technology, participants, trends, market size and share
- How does schedulerx help users solve the problem of distributed task scheduling?
- cookie、session、tooken
- The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
- What skills does an excellent software tester need to master?
- Review notes of compilation principles
- 【底部弹出-选择器】uniapp Picker组件——底部弹起的滚动选择器
- You probably haven't noticed the very important testing strategy in your work
猜你喜欢

Use es to realize epidemic map or take out order function (including code and data)

【八大排序④】归并排序、不基于比较的排序(计数排序、基数排序、桶排序)

Datawhale community blackboard newspaper (issue 1)
![[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login](/img/c1/23be4399119f42d85a7b86fc8a59fc.png)
[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login

Leetcode skimming: binary tree 03 (post order traversal of binary tree)

Slf4j print abnormal stack information

The pain of Xiao Sha

Keepalived introduction and installation

ACM教程 - 快速排序(常规 + 尾递归 + 随机基准数)

969 interlaced string
随机推荐
首场“移动云杯”空宣会,期待与开发者一起共创算网新世界!
Comprehensive broadcast of global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
S32Kxxx bootloader之UDS bootloader
Variables and constants of go language foundation
ACM tutorial - quick sort (regular + tail recursion + random benchmark)
How do Lenovo computers connect Bluetooth headsets?
sso单点登录的实现。
Keepalived introduction and installation
Leetcode skimming: stack and queue 02 (realizing stack with queue)
Output results of convolution operation with multiple tensors and multiple convolution kernels
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
gradle
The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
Xinniuniu blind box wechat applet source code_ Support flow realization, with complete material pictures
Excel search and reference function
Evolution of Himalayan self-developed gateway architecture
Leetcode skimming: stack and queue 05 (inverse Polish expression evaluation)
Basis of deep learning neural network
2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
2022 low voltage electrician examination questions and answers