当前位置:网站首页>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
边栏推荐
- Leetcode-6109: number of people who know secrets
- Dataframe (1): introduction and creation of dataframe
- WordPress switches the page, and the domain name changes back to the IP address
- MySQL advanced part 2: optimizing SQL steps
- How to generate an image from text on fly at runtime
- 安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
- 【LeetCode】Day95-有效的数独&矩阵置零
- MySQL advanced part 1: triggers
- SQL三种连接:内连接、外连接、交叉连接
- Sqlmap tutorial (1)
猜你喜欢
MySQL advanced part 2: MySQL architecture
Navicat连接Oracle数据库报错ORA-28547或ORA-03135
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
Traditional databases are gradually "difficult to adapt", and cloud native databases stand out
WordPress switches the page, and the domain name changes back to the IP address
Navicat連接Oracle數據庫報錯ORA-28547或ORA-03135
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
MySQL advanced part 2: optimizing SQL steps
求组合数 AcWing 888. 求组合数 IV
1.13 - RISC/CISC
随机推荐
AE tutorial - path growth animation
One question per day 1020 Number of enclaves
什么是套接字?Socket基本介绍
Currently clicked button and current mouse coordinates in QT judgment interface
[learning] database: MySQL query conditions have functions that lead to index failure. Establish functional indexes
JS quickly converts JSON data into URL parameters
Liunx starts redis
our solution
Matrixdb V4.5.0 was launched with a new mars2 storage engine!
5. Oracle TABLESPACE
Leetcode array operation
How to generate an image from text on fly at runtime
Leetcode heap correlation
Usage scenarios of golang context
7.Oracle-表结构
4. 对象映射 - Mapping.Mapster
FFmpeg build下载(包含old version)
Leetcode-22: bracket generation
Redis-02.Redis命令
Leetcode stack related