'commit'
This commit is contained in:
25
TangDou/LuoGuBook/P20_2.cpp
Normal file
25
TangDou/LuoGuBook/P20_2.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
const int N = 2010; //n的数值上限
|
||||
|
||||
int t; //t次查询
|
||||
int n; //n个数字中
|
||||
int m; //找m个数字组合
|
||||
int C[N][N]; //组合数数组
|
||||
int K = 100000;
|
||||
|
||||
|
||||
int main() {
|
||||
//预处理杨辉三角形
|
||||
for (int i = 0; i < N; i++) {
|
||||
//base case
|
||||
C[i][0] = 1, C[i][i] = 1;
|
||||
//递推生成其它组合数
|
||||
for (int j = 1; j < i; j++)
|
||||
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % k;
|
||||
}
|
||||
cin >> n >> m;
|
||||
cout << C[n][m] << endl;
|
||||
}
|
||||
Reference in New Issue
Block a user