当前位置:网站首页>Mathematical knowledge: finding combinatorial number I - finding combinatorial number
Mathematical knowledge: finding combinatorial number I - finding combinatorial number
2022-06-28 22:54:00 【Fight! Sao Nian!】
subject :AcWing 885. Find the combination number I
Given n Group inquiry , Each group is given two integers a,b, Please output Cbamod(109+7) Value .
Input format
The first line contains integers n.
Next n That's ok , Each line contains a set of a and b.
Output format
common n That's ok , Each line outputs a solution to the query .
Data range
1≤n≤10000,
1≤b≤a≤2000
sample input :
3
3 1
5 3
2 2
sample output :
3
10
1
Topic analysis :
According to the principle of addition and counting, there are :
Cba=Cb−1a−1+Cba−1
So you can preprocess first , Then directly look up the table
#include <iostream>
using namespace std;
const int N = 2010 ,mod = 1e9+7;
int c[N][N];
void init() // The value of the number of preprocessing combinations
{
for(int i=0;i<N;i++) // Can't be equal N Superboundary
for(int j=0;j<=i;j++)
if(!j)c[i][j]=1;
else c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
int main()
{
init();
int n;
cin>>n;
while(n--)
{
int a,b;
cin>>a>>b;
cout<<c[a][b]<<endl;
}
return 0;
}
边栏推荐
- 稳!上千微服务如何快速接入 Zadig(Helm Chart 篇)
- What is the difference between WMS warehouse management system and ERP
- 嵌入式中 动态阿拉伯语字符串 转换 LCD显示字符串【感谢建国雄心】
- What is the prospect of VR panoramic production?
- 在QT进行cin(全网最清晰教程)
- Oracle set password complexity and timeout exit function
- What is low code development?
- 穿越过后,她说多元宇宙真的存在
- Detailed steps for MySQL to recover data through IBD files
- Research Report on workers: middle-aged people account for the highest proportion of naked words
猜你喜欢

论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》

What does project management really manage?

Websocket for im instant messaging development: concept, principle and common sense of mistakes

Considerations on the construction of operation and maintenance system - stability

一文读懂,WMS仓储管理系统与ERP有什么区别

Wave picking of WMS warehouse management system module

On the necessity and solution of building a campus online teaching video convergence platform

Basic knowledge diagram of K-line Diagram -- meaning of single K-line

Ingénieur natif du nuage après 00: utiliser Zadig pour développer des sources ouvertes et des économies d'énergie pour la technologie innovante (bus de Guangzhou)

Realization of 2D code generation in micro build low code
随机推荐
SqlServer复习
如何结合均线分析伦敦金行情走势线图
Linux Installation mysql5.7 (centos7.6) tutorial
The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
Detailed explanation of Zadig's self-test and joint debugging sub environment for developers
Deep virtual memory (VM)
Zadig + cave Iast: let safety dissolve in continuous delivery
手机办理股票开户安全性高吗?
2022-06-28: what does the following golang code output? A:true; B:false; C:panic; D: Compilation failed. package main import “fmt“ func main() {
Sample code of using redis to realize the like function
Is it safe and reliable for changtou school to help open a securities account? How to drive
k线图基础知识图解——单根K线的含义
LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路
浅析搭建校园在线教学视频汇聚平台的必要性及解决方案
WMS仓库管理系统模块之波次拣货
Embedded dynamic Arabic string conversion LCD display string [thanks for Jianguo ambition]
Jointly explore digital technology and information security, and the fourth China Russia Digital Forum was successfully held
Oracle set password complexity and timeout exit function
Lost in cloud computing
Prometeus 2.36.0 新特性