当前位置:网站首页>求组合数 AcWing 889. 满足条件的01序列
求组合数 AcWing 889. 满足条件的01序列
2022-07-27 10:35: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);
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- NFT leaderboard -nft real offer latest address: NFT leaderboard.com
- 4 search insertion location
- 十年架构五年生活-07 年轻气盛的蜕变
- Self optimization of wireless cell load balancing based on machine learning technology
- Influence of black and white pixel distribution on iteration times
- 基于FPGA的ECG信号采集,存储以及传输系统verilog实现
- Non progressive phenomena of entropy and morphology
- Overview of radar communication integrated waveform design
- 背包模型 AcWing 1022. 宠物小精灵之收服
- KEPServer配置
猜你喜欢

Internal and external troubles of digital collection NFT "boring ape" bayc

Budweiser, a well-known beer, plans to launch NFT in an attempt to unveil the "long planned" uplink?

Kangaroo cloud stack based on CBO in spark SQL optimization

KEPServer配置

Wilderness search --- search iterations

迭代次数的差异与信息熵

背包模型 AcWing 1024. 装箱问题

Non progressive phenomena of entropy and morphology

MySQL installation (RPM package)

背包问题 AcWing 9. 分组背包问题
随机推荐
How to create a.Net image with diagnostic tools
Error: image clipToBoundsAndScale, argument 'input'
Ansible
解决 ImportError: cannot import name 'abs' 导入tensorflow报错
学习笔记-简易服务器实现
推导重叠积分的详细展开式 STO overlap integrals
Kangaroo cloud stack based on CBO in spark SQL optimization
Learning notes - wechat payment
ACM warm-up Exercise 2 in 2022 summer vacation (summary)
Wenzhou University X kangaroo cloud: how to "know well" in the construction of higher talent education
Chunjun supports DDL conversion and automatic execution of heterogeneous data sources - dtmo 02 review (including course playback + courseware)
IO stream_ Overview and explanation of data input and output flow
The article will not keep VIP charges all the time. It will be open for a period of time
荒野觅踪---寻找迭代次数
Wilderness search --- search iterations
Study notes Minio
KEPServer配置
Taishan Office Technology Lecture: scaling and opening files
高斯消元 AcWing 884. 高斯消元解异或线性方程组
IMG SRC is empty or SRC does not exist, and the picture has a white border