当前位置:网站首页>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;
}
边栏推荐
- The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
- Datawhale community blackboard newspaper (issue 1)
- Mathematics - feelings -20220215
- I'll teach you to visit Amazon RDS for a year and build a MySQL cloud database (only 10 minutes, really fragrant)
- Leetcode skimming: binary tree 01 (preorder traversal of binary tree)
- Comprehensive broadcast of global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
- ACM tutorial - quick sort (regular + tail recursion + random benchmark)
- XMIND mind map
- The first "mobile cloud Cup" empty publicity meeting, looking forward to working with developers to create a new world of computing!
- 关于ASP.NET CORE使用DateTime日期类型参数的一个小细节
猜你喜欢

Excel PivotTable

How to extract login cookies when JMeter performs interface testing

Weather forecast applet source code weather wechat applet source code

excel数据透视表

Picture puzzle wechat applet source code_ Support multi template production and traffic master

Promise和模块块化编程

工作中非常重要的测试策略,你大概没注意过吧

Schrodinger's Japanese learning applet source code

测试人进阶技能:单元测试报告应用指南

Leetcode skimming: stack and queue 04 (delete all adjacent duplicates in the string)
随机推荐
Xinniuniu blind box wechat applet source code_ Support flow realization, with complete material pictures
Review notes of compilation principles
Bubble Sort Graph
Schrodinger's Japanese learning applet source code
Cat Party (Easy Edition)
The pain of Xiao Sha
Friends circle community program source code sharing
To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"
ACM tutorial - quick sort (regular + tail recursion + random benchmark)
Global and Chinese market of avionics systems 2022-2028: Research Report on technology, participants, trends, market size and share
[leetcode] number of maximum consecutive ones
Global and Chinese markets of edge AI software 2022-2028: Research Report on technology, participants, trends, market size and share
@Valid parameter verification does not take effect
excel数据透视表
Bc35 & bc95 onenet mqtt (old)
excel查找与引用函数
【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能
Leetcode skimming: stack and queue 03 (valid parentheses)
Leetcode skimming: stack and queue 04 (delete all adjacent duplicates in the string)
Excel PivotTable