当前位置:网站首页>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
边栏推荐
- 高斯消元 AcWing 884. 高斯消元解异或線性方程組
- 背包问题 AcWing 9. 分组背包问题
- Leetcode recursion
- 4. Oracle redo log file management
- 快速使用Amazon MemoryDB并构建你专属的Redis内存数据库
- Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
- MySQL advanced part 2: the use of indexes
- 求组合数 AcWing 887. 求组合数 III
- [2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
- 3. Oracle control file management
猜你喜欢
AE tutorial - path growth animation
3.Oracle-控制文件的管理
4.Oracle-重做日志文件管理
MySQL advanced part 2: optimizing SQL steps
Open source storage is so popular, why do we insist on self-development?
LeetCode-61
传统数据库逐渐“难适应”,云原生数据库脱颖而出
求组合数 AcWing 888. 求组合数 IV
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
[moviepy] unable to find a solution for exe
随机推荐
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
1.13 - RISC/CISC
MySQL advanced part 2: optimizing SQL steps
Golang uses context gracefully
背包问题 AcWing 9. 分组背包问题
WordPress switches the page, and the domain name changes back to the IP address
Winter messenger 2
MySQL advanced part 1: triggers
P2575 master fight
Sword finger offer II 058: schedule
1.14 - assembly line
论文阅读报告
RecyclerView的应用
C - XOR to all (binary topic)
C job interview - casting and comparing - C job interview - casting and comparing
__ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
Niu Mei's math problems
传统数据库逐渐“难适应”,云原生数据库脱颖而出
Leetcode dynamic programming
Sqlmap tutorial (1)