当前位置:网站首页>求组合数 AcWing 889. 满足条件的01序列
求组合数 AcWing 889. 满足条件的01序列
2022-07-05 06:16:00 【T_Y_F666】
求组合数 AcWing 889. 满足条件的01序列
原题链接
算法标签
组合数学 组合计数 卡特兰数 逆元 快速幂 费马小定理
思路

代码
#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 需求逆元
rep(i, 1, n+2){
res=res*qmi(i, mod-2, mod)%mod;
}
printf("%lld\n", res);
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- MySQL advanced part 1: stored procedures and functions
- [rust notes] 13 iterator (Part 2)
- MatrixDB v4.5.0 重磅发布,全新推出 MARS2 存储引擎!
- MySQL advanced part 2: optimizing SQL steps
- Arduino 控制的 RGB LED 无限镜
- MySQL advanced part 2: SQL optimization
- Sword finger offer II 058: schedule
- Golang uses context gracefully
- CPU内核和逻辑处理器的区别
- MySQL advanced part 2: MySQL architecture
猜你喜欢
随机推荐
CPU内核和逻辑处理器的区别
【Rust 笔记】13-迭代器(中)
[rust notes] 16 input and output (Part 2)
SPI details
leetcode-6109:知道秘密的人数
1039 Course List for Student
【Rust 笔记】14-集合(上)
[rust notes] 14 set (Part 1)
【Rust 笔记】15-字符串与文本(上)
【Rust 笔记】17-并发(上)
LeetCode-54
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
Chapter 6 relational database theory
Arduino 控制的 RGB LED 无限镜
Leetcode-6110: number of incremental paths in the grid graph
[leetcode] day95 effective Sudoku & matrix zeroing
多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
Data visualization chart summary (II)
一些工具的记录2022
Nested method, calculation attribute is not applicable, use methods








