当前位置:网站首页>Mathematical knowledge: 01 sequence satisfying conditions - find combinatorial number
Mathematical knowledge: 01 sequence satisfying conditions - find combinatorial number
2022-07-01 01:39:00 【Fight! Sao Nian!】
subject :AcWing 889. Satisfied 01 Sequence
Given n individual 0 and n individual 1, They will be arranged in some order with a length of 2n Sequence , Find all the sequences they can be arranged into , Can satisfy any prefix sequence 0 The number of is no less than 1 How many are there in the sequence of the number of .
The output answer is right 109+7 modulus .
Input format
All in one line , Contains integers n.
Output format
All in one line , Contains an integer , Answer .
Data range
1≤n≤105
sample input :
3
sample output :
5
Topic analysis :
Combination count , Carter LAN number
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 100010,mod = 1e9+7;
int qmi(int a,int k,int p)
{
int res=1;
while(k)
{
if(k&1)res=(LL)res*a%p;
a=(LL)a*a%p;
k>>=1;
}
return res;
}
int main()
{
int n;
cin>>n;
int a=n*2,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;
res=(LL)res*qmi(n+1,mod-2,mod)%mod;
cout<<res<<endl;
return 0;
}
边栏推荐
猜你喜欢
PHP通过第三方插件爬取数据
After working for 6 years, let's take stock of the golden rule of the workplace where workers mix up
Digital IC design process summary
"Open math input panel" in MathType editing in win11 is gray and cannot be edited
7-2 拼题A打卡奖励 dp
One of the basics - overview of sta Basics
Note d'étude du DC: zéro dans le chapitre officiel - - Aperçu et introduction du processus de base
物业怎么发短信通知给业主?
Qt5 mvc: revealing the secrets of data visualization
Exploration and practice of "flow batch integration" in JD
随机推荐
农产品换房?“变相”购房补贴!
Compile and install oh my Zsh
医疗HIS行业短信发送解决方案
opencv -- 笔记
Strictmode jamming and leakage detection -strictmode principle (2)
dc_ Study and summary of labs--lab1
C # customize and dynamically switch cursor
尝试新的可能
System settings large page
PHP converts two-dimensional array elements into key value pairs
正向代理和反向代理快速理解
图的连通性基础
TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to
一站式洞察行业热点,飞瓜数据B站新功能「流量大盘」上线!
[stack] 921 Minimum Add to Make Parentheses Valid
gin_gorm
gin_ gorm
亲测有效,快速创建JMeter桌面快捷方式
软件测试的可持续发展,必须要学会敲代码?
【模拟】922. Sort Array By Parity II