'commit'
This commit is contained in:
24
TangDou/LuoGuBook/20_8_2.cpp
Normal file
24
TangDou/LuoGuBook/20_8_2.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include<cstdio>
|
||||
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
|
||||
//帕斯卡公式求组合数,与埃筛、欧筛类似,是预处理中好多,再慢慢用
|
||||
const int N = 2010; //n的数值上限
|
||||
LL C[N][N]; //组合数数组
|
||||
void C3() {
|
||||
//预处理杨辉三角形
|
||||
for (int i = 0; i < N; i++) {
|
||||
//base case
|
||||
C[i][0] = C[i][i] = 1; //组合数C(n,0)=1 组合数C(n,n)=c(n,0)=1
|
||||
//递推生成其它组合数
|
||||
for (int j = 1; j < i; j++)
|
||||
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
C3();
|
||||
printf("%lld\n", C[54][17]);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user