Files
python/TangDou/LuoGuBook/P2638.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

28 lines
646 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
//https://www.luogu.com.cn/blog/x4Cx58x54/solution-p2638
//经典题
using namespace std;
typedef unsigned long long ULL;
int n, a, B;
ULL ans;
//求组合数的优化后办法
//优点:从1开始除和乘,可以防止过早溢出和除法除不尽
ULL C(int n, int m) {
ULL sum = 1;
for (int i = 1; i <= m; i++)
sum = sum * (n - m + i) / i;
return sum;
}
int main() {
cin >> n >> a >> b;
for (int i = 0; i <= a; i++)
for (int j = 0; j <= b; j++)
ans += C(n + i - 1, n - 1) * C(n + j - 1, n - 1);
cout << ans << endl;
return 0;
}