当前位置:网站首页>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
边栏推荐
- Unity editor expansion - scrolling list
- Unity editor expansion - controls, layouts
- TP5 order multi condition sort
- Campus lost and found platform based on SSM, source code, database script, project import and operation video tutorial, Thesis Writing Tutorial
- Query XML documents with XPath
- JS non Boolean operation - learning notes
- Drawing maze EasyX library with recursive backtracking method
- Development experience and experience
- Vscode, idea, VIM development tool shortcut keys
- Find the intersection of line segments
猜你喜欢
UE4 source code reading_ Mobile synchronization
Monotonic stack -503 Next bigger Element II
SQL statement error of common bug caused by Excel cell content that is not paid attention to for a long time
Vscode, idea, VIM development tool shortcut keys
How to use Jupiter notebook
Drawing maze EasyX library with recursive backtracking method
[rust notes] 02 ownership
Concurrent programming (V) detailed explanation of atomic and unsafe magic classes
DOM 渲染系统(render mount patch)响应式系统
Format - C language project sub file
随机推荐
MySQL three logs
Unity Editor Extension - event handling
XPath实现XML文档的查询
Solution of 300ms delay of mobile phone
Binary tree sorting (C language, int type)
Phpstudy 80 port occupied W10 system
数据库原理期末复习
Es8 async and await learning notes
[rust notes] 07 structure
第一个Servlet
Alibaba canaladmin deployment and canal cluster Ha Construction
JS ternary operator - learning notes (with cases)
How to use Jupiter notebook
使用dlv分析golang进程cpu占用高问题
请求参数的发送和接收
Development experience and experience
Try to reprint an article about CSDN reprint
DOM 渲染系统(render mount patch)响应式系统
Pit & ADB wireless debugging of vivo real machine debugging
Dom4j traverses and updates XML