当前位置:网站首页>Find the combination number acwing 885 Find the combination number I
Find the combination number acwing 885 Find the combination number I
2022-07-03 08:51:00 【T_ Y_ F666】
Find the combination number AcWing 885. Find the combination number I
Original link
AcWing 885. Find the combination number I
Algorithm tags
Combinatorial mathematics Combination count Recurrence
Ideas

Code
#include<bits/stdc++.h>
#define int long long
#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 = 2005, mod = 1e9+7;
int c[N][N];
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);
}
void init(){
rep(i, 0, N){
rep(j, 0, i+1){
// from i Select the 0 individual The number of programmes is 1
if(!j){
c[i][j]=1;
}else{
c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
}
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n=read();
init();
while(n--){
int a=read(), b=read();
printf("%lld\n", c[a][b]);
}
return 0;
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support 
边栏推荐
- too many open files解决方案
- 22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
- UE4 source code reading_ Bone model and animation system_ Animation compression
- Notes on understanding applets 2022/7/3
- [redis] redis persistent RDB vs AOF (source code)
- Phpstudy 80 port occupied W10 system
- createjs easeljs
- Monotonic stack -42 Connect rainwater
- Binary tree sorting (C language, int type)
- On the difference and connection between find and select in TP5 framework
猜你喜欢

DOM 渲染系统(render mount patch)响应式系统

MySQL 8

Notes on understanding applets 2022/7/3
![[concurrent programming] thread foundation and sharing between threads](/img/26/60fbfe65b186867a3b1cb58d481226.jpg)
[concurrent programming] thread foundation and sharing between threads

Six dimensional space (C language)

Log4j2 vulnerability recurrence and analysis

UE4 source code reading_ Bone model and animation system_ Animation node
![[concurrent programming] consistency hash](/img/5e/3d0a52caa8ca489a6e6267274bbb39.jpg)
[concurrent programming] consistency hash

Message queue for interprocess communication

too many open files解决方案
随机推荐
Deeply understand the underlying data structure of MySQL index
Redux - learning notes
Escape from heaven and forget what he suffered. In ancient times, it was called the punishment of escape from heaven. Article collection
Downward compatibility and upward compatibility
[concurrent programming] concurrent security
Unity Editor Extension - drag and drop
Unity interactive water ripple post-treatment
On the difference and connection between find and select in TP5 framework
XPath实现XML文档的查询
高斯消元 AcWing 883. 高斯消元解线性方程组
Alibaba canal actual combat
[rust notes] 08 enumeration and mode
【Rust 笔记】12-闭包
[linear table] basic operation of bidirectional linked list specify node exchange
TP5 multi condition sorting
Unity Editor Extension - Outline
22-05-26 Xi'an interview question (01) preparation
Development experience and experience
Facial expression recognition based on pytorch convolution -- graduation project
Campus lost and found platform based on SSM, source code, database script, project import and operation video tutorial, Thesis Writing Tutorial