Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- using ll = long long;
- using ld = long double;
- using pii = pair<int, int>;
- constexpr int N = 2e5 + 5;
- constexpr int mod = 998244353;
- int n, m;
- int ans = 0;
- int fact[N], rfact[N];
- int sum(ll a, ll b) {
- return (a + b) % mod;
- }
- int mul(ll a, ll b) {
- return (a * b) % mod;
- }
- int binpow(int v, int deg) {
- int cur = 1;
- while(deg) {
- if (deg & 1)
- cur = mul(cur, v);
- v = mul(v, v);
- deg >>= 1;
- }
- return cur;
- }
- int C(int i, int j) {
- return mul(fact[i], mul(rfact[i - j], rfact[j]));
- }
- void Solve() {
- cin >> n >> m;
- fact[0] = 1;
- for (int i = 1; i <= m; i++)
- fact[i] = mul(fact[i - 1], i);
- rfact[m] = binpow(fact[m], mod - 2);
- for (int i = m - 1; i >= 0; i--)
- rfact[i] = mul(rfact[i + 1], i + 1);
- for (int i = 2; i < n; i++) {
- for (int j = max(i, n - 1); j <= m; j++)
- ans = sum(ans, mul(C(j - 1, i - 1), C(j - i, n - i - 1)));
- }
- cout << ans;
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- //auto start = chrono::high_resolution_clock::now();
- Solve();
- //auto end = chrono::high_resolution_clock::now();
- //cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement