当前位置:网站首页>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.8.4-PointersOnC-20220215
- [bottom pop-up selector] uniapp picker component - scroll selector popped up at the bottom
- 【八大排序②】选择排序(选择排序,堆排序)
- Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
- Global and Chinese markets for freight and logistics 2022-2028: Research Report on technology, participants, trends, market size and share
- Leetcode skimming: stack and queue 02 (realizing stack with queue)
- cookie、session、tooken
- The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
- Collection: comprehensive summary of storage knowledge
- SSO single sign on implementation.
猜你喜欢

XMIND mind map

gradle

Kuberntes cloud native combat high availability deployment architecture

2022 low voltage electrician examination questions and answers

Review notes of compilation principles

How does schedulerx help users solve the problem of distributed task scheduling?

excel查找与引用函数

Infiltration records of CFS shooting range in the fourth phase of the western regions' Dadu Mansion

Leetcode skimming: binary tree 02 (middle order traversal of binary tree)

Leetcode skimming: stack and queue 01 (realizing queue with stack)
随机推荐
Weather forecast applet source code weather wechat applet source code
Global and Chinese market of collaborative applications 2022-2028: Research Report on technology, participants, trends, market size and share
JS -- image to base code, base to file object
测试人进阶技能:单元测试报告应用指南
Minimize the error
Barbie q! How to analyze the new game app?
BPR (Bayesian personalized sorting)
Mathematics - feelings -20220215
2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
Advanced skills of testers: a guide to the application of unit test reports
To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"
Global and Chinese market of picture archiving and communication system (PACS) 2022-2028: Research Report on technology, participants, trends, market size and share
[conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)
Global and Chinese markets of edge AI software 2022-2028: Research Report on technology, participants, trends, market size and share
Entrepreneurship is a little risky. Read the data and do a business analysis
From 20s to 500ms, I used these three methods
Node - generate wechat permission verification configuration
How to reflect and solve the problem of bird flight? Why are planes afraid of birds?
How does schedulerx help users solve the problem of distributed task scheduling?
How do Lenovo computers connect Bluetooth headsets?