当前位置:网站首页>求组合数 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);
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- C Primer Plus Chapter 15 (bit operation)
- MIT-6874-Deep Learning in the Life Sciences Week 7
- LeetCode 0107. Sequence traversal of binary tree II - another method
- Groupbykey() and reducebykey() and combinebykey() in spark
- Leetcode heap correlation
- 对for(var i = 0;i < 5;i++) {setTimeout(() => console.log(i),1000)}的深入分析
- 博弈论 AcWing 891. Nim游戏
- 打印机脱机时一种容易被忽略的原因
- Records of some tools 2022
- [rust notes] 16 input and output (Part 2)
猜你喜欢

SQLMAP使用教程(一)

Appium基础 — 使用Appium的第一个Demo

NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar

Matrixdb V4.5.0 was launched with a new mars2 storage engine!

MySQL advanced part 2: storage engine

leetcode-6111:螺旋矩阵 IV

MySQL advanced part 1: View

LeetCode-61
![[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis](/img/20/826cc9d514496955a557439881234d.jpg)
[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis

博弈论 AcWing 894. 拆分-Nim游戏
随机推荐
1041 Be Unique
【Rust 笔记】17-并发(上)
Leetcode-6109: number of people who know secrets
1040 Longest Symmetric String
Leetcode array operation
多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
Doing SQL performance optimization is really eye-catching
js快速将json数据转换为url参数
leetcode-6111:螺旋矩阵 IV
Traversal of leetcode tree
Spark中groupByKey() 和 reduceByKey() 和combineByKey()
背包问题 AcWing 9. 分组背包问题
Appium自动化测试基础 — Appium测试环境搭建总结
Leetcode-6110: number of incremental paths in the grid graph
阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
LeetCode-61
1039 Course List for Student
1.13 - RISC/CISC
A reason that is easy to be ignored when the printer is offline
Leetcode divide and conquer / dichotomy