当前位置:网站首页>求组合数 AcWing 885. 求组合数 I
求组合数 AcWing 885. 求组合数 I
2022-07-27 10:35:00 【T_Y_F666】
求组合数 AcWing 885. 求组合数 I
原题链接
算法标签
组合数学 组合计数 递推
思路

代码
#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){
// 从i中选取0个 方案数为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;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- 深析C语言的灵魂 -- 指针
- 推导重叠积分的详细展开式 STO overlap integrals
- Antd table+checkbox default value display
- 背包模型 AcWing 1022. 宠物小精灵之收服
- IO流_字符流、IO流小结、IO流案例总结
- Verilog implementation of ECG signal acquisition, storage and transmission system based on FPGA
- Internal and external troubles of digital collection NFT "boring ape" bayc
- Chengying, kangaroo cloud one-stop fully automated operation and maintenance steward, is officially open source
- ethereum rpc
- Overview of radar communication integrated waveform design
猜你喜欢

49字母异位分组和242有效的字母异位词

熵与形态的非递进现象

A verification test of the relationship between iteration number and entropy

数字三角形模型 AcWing 275. 传纸条

Longest ascending subsequence model acwing 1014. mountaineering

Internal and external troubles of digital collection NFT "boring ape" bayc

ethereum rpc

计算重叠积分的第二种方法

Derive the detailed expansion of STO double center kinetic energy integral

Instructions for mock platform
随机推荐
Integrated design of communication perception based on CSI: problems, challenges and Prospects
How to assemble a registry
涌现与形态的局部差异和整体差异
Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
Ansible
背包模型 AcWing 1022. 宠物小精灵之收服
Instructions for mock platform
7 row K with the weakest combat effectiveness in the matrix
Play with the cluster configuration center and learn about the Taier console
栈 AcWing 3302. 表达式求值
Learning notes uni app
[QNX hypervisor 2.2 user manual]9.9 logger
学习笔记-minio
The open source project Taier version 1.1 was officially released, and the list of new functions is fast
Sort th in antd table to prevent hovering color change +table hovering row color change +table header color change
Research on synaesthesia integration and its challenges
深析C语言的灵魂 -- 指针
Yiwen counts NFT projects valued at more than US $100million
IO流_字符流、IO流小结、IO流案例总结
推导重叠积分的详细展开式 STO overlap integrals