当前位置:网站首页>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 
边栏推荐
- How to place the parameters of the controller in the view after encountering the input textarea tag in the TP framework
- Slice and index of array with data type
- The method for win10 system to enter the control panel is as follows:
- createjs easeljs
- Unity editor expansion - draw lines
- Character pyramid
- too many open files解决方案
- [rust notes] 08 enumeration and mode
- First Servlet
- 22-06-27 西安 redis(01) 安装redis、redis5种常见数据类型的命令
猜你喜欢

Collection interface

First Servlet

JS ternary operator - learning notes (with cases)

Binary to decimal, decimal to binary

Unity interactive water ripple post-treatment

Binary tree sorting (C language, int type)

Annotations simplify configuration and loading at startup

记忆化搜索 AcWing 901. 滑雪
![[concurrent programming] concurrent tool class of thread](/img/16/2b4d2b3528b138304a1a3918773ecf.jpg)
[concurrent programming] concurrent tool class of thread

Notes on understanding applets 2022/7/3
随机推荐
【Rust 笔记】11-实用特型
Apache startup failed phpstudy Apache startup failed
Chocolate installation
C language student management system based on linked list, super detailed
Unity Editor Extension - event handling
[MySQL] MySQL Performance Optimization Practice: introduction of database lock and index search principle
Unity interactive water ripple post-treatment
Development material set
php public private protected
Unity editor expansion - scrolling list
Eating fruit
Redux - learning notes
Development experience and experience
Graphics_ Games101/202 learning notes
PHP function date (), y-m-d h:i:s in English case
记忆化搜索 AcWing 901. 滑雪
Constraintlayout's constraintset dynamically modifies constraints
[concurrent programming] collaboration between threads
Annotations simplify configuration and loading at startup
Binary tree sorting (C language, int type)