当前位置:网站首页>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;
}
边栏推荐
- Unknown database connection database error
- mysql数据库基础:流程控制
- MYSQL 数据库查看磁盘占用情况
- 3dsmax plug-in development traversal node object and object acquisition and inode transformation matrix description
- Composants de la grille de données portatifs
- Exploration and practice of "flow batch integration" in JD
- Qt5 mvc: revealing the secrets of data visualization
- Log4j2 ThreadContext日志链路追踪
- What are the functions of soil microorganisms in microbial detection?
- 微生物安全與健康,什麼是生物處理?
猜你喜欢

迪赛智慧数——其他图表(平行坐标图):2021年应届专业就业情况

3500字归纳总结:一名合格的软件测试工程师需要掌握的技能大全

For the sustainable development of software testing, we must learn to knock code?

物业怎么发短信通知给业主?

Zero of DC learning notes -- overview and basic process introduction

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

New opportunities for vr/ar brought by metauniverse

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

使用 C# 创造 ASCII 艺术

1500w播放下还藏着什么热点?B站2个未来趋势你不得错过
随机推荐
视频教程 | 长安链推出系列视频教程合集(入门)
正向代理和反向代理快速理解
Note d'étude du DC: zéro dans le chapitre officiel - - Aperçu et introduction du processus de base
Composants de la grille de données portatifs
数学知识:求组合数 IV—求组合数
Creating ASCII art with C #
QT5-布局在创作中的理解应用
TypeError: Argument ‘angle‘ can not be treated as a double
System settings large page
[Qt5 basics] random number display
数据探索电商平台用户行为流失分析
Gin configuration file
[dynamic planning] path dp:931 Minimum Falling Path Sum
日志 logrus第三方库的使用
【模拟】922. Sort Array By Parity II
孙宇晨接受瑞士媒体Bilan采访:熊市不会持续太久
Try new possibilities
laravel 事件 & 订阅
关于白盒测试,这些技巧你得游刃有余~
微生物检测,土壤微生物的作用有哪些?