当前位置:网站首页>求组合数 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);
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- QQ电脑版取消转义符输入表情
- Simple selection sort of selection sort
- __ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
- Sum of three terms (construction)
- 1.13 - RISC/CISC
- Leetcode-31: next spread
- [BMZCTF-pwn] ectf-2014 seddit
- 一些工具的记录2022
- LeetCode 0108. Convert an ordered array into a binary search tree - the median of the array is the root, and the left and right of the median are the left and right subtrees respectively
- 博弈论 AcWing 891. Nim游戏
猜你喜欢
数据可视化图表总结(二)
QQ电脑版取消转义符输入表情
SPI details
Appium foundation - use the first demo of appium
Leetcode-6110: number of incremental paths in the grid graph
Real time clock (RTC)
liunx启动redis
LeetCode 0107. Sequence traversal of binary tree II - another method
Data visualization chart summary (II)
背包问题 AcWing 9. 分组背包问题
随机推荐
[rust notes] 14 set (Part 2)
Leetcode array operation
Is it impossible for lamda to wake up?
Leetcode heap correlation
leetcode-6111:螺旋矩阵 IV
Introduction to LVS [unfinished (semi-finished products)]
leetcode-6109:知道秘密的人数
Chapter 6 relational database theory
js快速将json数据转换为url参数
【LeetCode】Day95-有效的数独&矩阵置零
中国剩余定理 AcWing 204. 表达整数的奇怪方式
LeetCode 0107. Sequence traversal of binary tree II - another method
Leetcode dynamic programming
Leetcode stack related
容斥原理 AcWing 890. 能被整除的数
Open source storage is so popular, why do we insist on self-development?
Leetcode-9: palindromes
【Rust 笔记】14-集合(下)
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
Leetcode-1200: minimum absolute difference