当前位置:网站首页>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
边栏推荐
- Navicat連接Oracle數據庫報錯ORA-28547或ORA-03135
- Leetcode backtracking method
- C Primer Plus Chapter 15 (bit operation)
- 1.14 - assembly line
- 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
- 4. Object mapping Mapster
- MySQL advanced part 1: View
- MySQL advanced part 1: index
- What's wrong with this paragraph that doesn't work? (unresolved)
- Leetcode-6110: number of incremental paths in the grid graph
猜你喜欢
Leetcode stack related
[wustctf2020] plain_ WP
AE tutorial - path growth animation
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
容斥原理 AcWing 890. 能被整除的数
Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
Alibaba established the enterprise digital intelligence service company "Lingyang" to focus on enterprise digital growth
MySQL advanced part 2: MySQL architecture
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
随机推荐
AE tutorial - path growth animation
WordPress switches the page, and the domain name changes back to the IP address
什么是套接字?Socket基本介绍
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
[wustctf2020] plain_ WP
求组合数 AcWing 889. 满足条件的01序列
求组合数 AcWing 887. 求组合数 III
Operator priority, one catch, no doubt
How to generate an image from text on fly at runtime
Ffmpeg build download (including old version)
Niu Mei's math problems
MySQL advanced part 1: stored procedures and functions
ADG5412FBRUZ-RL7应用 双电源模拟开关和多路复用器IC
Leetcode array operation
MySQL advanced part 2: storage engine
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
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
In depth analysis of for (VaR I = 0; I < 5; i++) {settimeout (() => console.log (I), 1000)}
JS quickly converts JSON data into URL parameters
Golang uses context gracefully