当前位置:网站首页>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 
边栏推荐
- 22-06-28 Xi'an redis (02) persistence mechanism, entry, transaction control, master-slave replication mechanism
- [set theory] order relation (total order relation | total order set | total order relation example | quasi order relation | quasi order relation theorem | bifurcation | quasi linear order relation | q
- too many open files解决方案
- Analysis of Alibaba canal principle
- 【Rust 笔记】07-结构体
- Es8 async and await learning notes
- Animation_ IK overview
- Notes on understanding applets 2022/7/3
- Unity editor expansion - window, sub window, menu, right-click menu (context menu)
- Drawing maze EasyX library with recursive backtracking method
猜你喜欢

VIM learning notes from introduction to silk skating

高斯消元 AcWing 883. 高斯消元解线性方程组

too many open files解决方案
![[concurrent programming] consistency hash](/img/5e/3d0a52caa8ca489a6e6267274bbb39.jpg)
[concurrent programming] consistency hash

Sending and receiving of request parameters

Final review of Database Principles

Binary tree sorting (C language, char type)

Log4j2 vulnerability recurrence and analysis

Parameters of convolutional neural network

Monotonic stack -42 Connect rainwater
随机推荐
[MySQL] MySQL Performance Optimization Practice: introduction of database lock and index search principle
Deep parsing (picture and text) JVM garbage collector (II)
Dom4j遍历和更新XML
Constraintlayout's constraintset dynamically modifies constraints
Get the link behind? Parameter value after question mark
Unity editor expansion - draw lines
Common DOS commands
Monotonic stack -84 The largest rectangle in the histogram
Notes and bugs generated during the use of h:i:s and y-m-d
22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
Dom4j traverses and updates XML
VIM learning notes from introduction to silk skating
Gradle's method of dynamically modifying APK package name
单调栈-42. 接雨水
Markdown directory generation
Baidu editor ueeditor changes style
Unity multi open script
【Rust 笔记】08-枚举与模式
Life cycle of Servlet
Monotonic stack -503 Next bigger Element II