当前位置:网站首页>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;
}
边栏推荐
- 1175. Prime Arrangements
- Selenium经典面试题-多窗口切换解决方案
- The argument type 'function' can't be assigned to the parameter type 'void function()‘
- 【office办公-pdf篇】pdf合并与拆分让我们摆脱付费软件的功能限制好不好
- 3dsmax插件开发遍历节点对象和Object获取及INode变换矩阵说明
- Thinking brought by strictmode -strictmode principle (5)
- 【Qt5-基础篇】随机数显示屏展示
- 未来的 Web3会带来什么?
- Some essential differences
- 使用 C# 创造 ASCII 艺术
猜你喜欢

1500w播放下还藏着什么热点?B站2个未来趋势你不得错过

One of the basics - overview of sta Basics

Basic knowledge II - Basic definitions related to sta

Test essential tool - postman practical tutorial

Ks009 implementation of pet management system based on SSH

The personal test is effective, and the JMeter desktop shortcut is quickly created

gin_ gorm

Qt5 mvc: revealing the secrets of data visualization

Digital IC design process summary

With regard to the white box test, you have to master these skills~
随机推荐
数学知识:求组合数 III—求组合数
医疗HIS行业短信发送解决方案
Strictmode jamming and leakage detection -strictmode principle (2)
laravel Carbon 时间处理类使用
二季度最后一天
flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘
Strictmode analysis registration strictmode principle (4)
PHP converts two-dimensional array elements into key value pairs
Strictmode analysis activity leakage -strictmode principle (3)
Last day of the second quarter
PHP数组拼接MySQL的in语句
[Qt5 tab] tab label and content hierarchical analysis
【Qt5-基础篇_1】从0开始,德天老师和你一起学习——窗口简介
Thinking brought by strictmode -strictmode principle (5)
【qt5-tab标签精讲】Tab标签及内容分层解析
【队列】933. Number of Recent Calls
Why build a personal blog
3500字归纳总结:一名合格的软件测试工程师需要掌握的技能大全
Necessary tools for testing - postman practical tutorial
1500w播放下还藏着什么热点?B站2个未来趋势你不得错过