当前位置:网站首页>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;
}
边栏推荐
- 【队列】933. Number of Recent Calls
- 用 Flutter 的 Canvas 画点有趣的图形
- 如何选择券商?另外,手机开户安全么?
- Ks009 implementation of pet management system based on SSH
- 物业怎么发短信通知给业主?
- Handsontable数据网格组件
- gin_ gorm
- [Qt5 basic \u 1] starting from 0, Mr. Detian will study with you - Introduction to the window
- laravel 事件 & 订阅
- Working for eight years as a programmer, but with a salary of three years after graduation, it's too late to be enlightened again
猜你喜欢

Necessary tools for testing - postman practical tutorial

With regard to the white box test, you have to master these skills~

测试必备工具-Postman实战教程

亲测有效,快速创建JMeter桌面快捷方式

qt5-MVC:数据可视化的层次揭秘

Institute of Microbiology, commonly used biochemical reactions in microbiological testing

医疗HIS行业短信发送解决方案

Ks009 implementation of pet management system based on SSH

远程办公如何保持高效协同,实现项目稳定增长 |社区征文

flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘
随机推荐
正向代理和反向代理快速理解
【agora】用户管理
System. Csrebot for commandline
sort自定义函数
Exploration and practice of "flow batch integration" in JD
工作6年,来盘点一下职场人混迹职场的黄金法则
数学知识:求组合数 III—求组合数
微生物检测,土壤微生物的作用有哪些?
System settings large page
gin_ gorm
[Office PDF] PDF merging and splitting will free us from the functional limitations of paid software, OK
What will Web3 bring in the future?
[Qt5 basic \u 1] starting from 0, Mr. Detian will study with you - Introduction to the window
Visual studio 2019 Download
数学知识:求组合数 IV—求组合数
孙宇晨接受瑞士媒体Bilan采访:熊市不会持续太久
laravel Carbon 时间处理类使用
未来的 Web3会带来什么?
微生物健康,食品微生物检测为什么很重要
laravel 事件 & 订阅