提交时间:2024-08-20 21:59:25

运行 ID: 173600

#include <iostream> #include <cstring> using namespace std; // 计算阶乘的函数 long long factorial(int n) { long long res = 1; for (int i = 2; i <= n; i++) { res *= i; } return res; } // 计算组合数的函数 long long combination(int m, int n) { long long numerator = factorial(m + n - 2); long long denominator = factorial(m - 1) * factorial(n - 1); return numerator / denominator; } int main() { int m, n; cin >> m >> n; cout << combination(m, n) << endl; return 0; }