当前位置:网站首页>Find the combination number acwing 889 01 sequence meeting conditions
Find the combination number acwing 889 01 sequence meeting conditions
2022-07-05 06:24:00 【T_ Y_ F666】
Find the combination number AcWing 889. Satisfied 01 Sequence
Original link
AcWing 889. Satisfied 01 Sequence
Algorithm tags
Combinatorial mathematics Combination count Carter LAN number Inverse element Fast power Fermat's small Theorem
Ideas

Code
#include<bits/stdc++.h>
#define int long long
#define abs fabs
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 100005, mod = 1e9+7;
int pr[N], st[N], s[N], cnt;
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
int qmi(int a, int b, int p){
int ans=1;
while(b){
if(b&1){
ans=ans*a%p;
}
a=a*a%p;
b>>=1;
}
return ans;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n=read();
int res=1;
// Cn 2n
Rep(i, 2*n, n+1){
res=res*i%mod;
}
// / n + 1 % p Demand inverse element
rep(i, 1, n+2){
res=res*qmi(i, mod-2, mod)%mod;
}
printf("%lld\n", res);
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support 
边栏推荐
- Quickly use Amazon memorydb and build your own redis memory database
- [rust notes] 14 set (Part 1)
- 2022-5-第四周日报
- 求组合数 AcWing 889. 满足条件的01序列
- Real time clock (RTC)
- [rust notes] 17 concurrent (Part 1)
- Records of some tools 2022
- 3.Oracle-控制文件的管理
- New title of module a of "PanYun Cup" secondary vocational network security skills competition
- Filter the numbers and pick out even numbers from several numbers
猜你喜欢
随机推荐
How to generate an image from text on fly at runtime
Suppose a bank's ATM machine, which allows users to deposit and withdraw money. Now there is 200 yuan in an account, and both user a and user B have the right to deposit and withdraw money from this a
5.Oracle-錶空間
Shutter web hardware keyboard monitoring
LeetCode-54
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
[rust notes] 17 concurrent (Part 1)
4. Oracle redo log file management
Leetcode-6111: spiral matrix IV
Traversal of leetcode tree
2022/6/29-日报
Leetcode dynamic programming
What's wrong with this paragraph that doesn't work? (unresolved)
Leetcode backtracking method
There are three kinds of SQL connections: internal connection, external connection and cross connection
MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
RecyclerView的应用
Nested method, calculation attribute is not applicable, use methods
LeetCode-61
MySQL advanced part 2: optimizing SQL steps








