题解 | #数组构造#
数组构造
https://www.nowcoder.com/practice/10c7508223834e259831d51806ad99d3
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000; const long long mod = 998244353; vector<long long> fac(maxn), ifac(maxn); long long mul(long long a, long long b) { return 1ll * a * b % mod; } long long qpow(long long a, long long b) { long long ret(1); while (b) { if (b & 1) ret = mul(ret, a); a = mul(a, a); b >>= 1 ; } return ret; } long long C(int n,int m){ return mul(fac[n],mul(ifac[n-m],ifac[m])); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); fac[0] = 1; for (int i = 1; i < maxn; i++ ) fac[i] = mul(fac[i - 1], i); ifac[maxn - 1] = qpow(fac[maxn - 1], mod - 2); for (int i = maxn - 2; ~i; i--) ifac[i] = mul(ifac[i + 1], i + 1); int n, m; cin >> n >> m; cout << C(n + 2 * m - 1, 2 * m) << endl; return 0; }