Problem - 1312D - Codeforces
题意:
思路:
Code:
#include <bits/stdc++.h>
#define int long long
using i64 = long long;
constexpr int N = 2e5 + 10;
constexpr int M = 2e5 + 10;
constexpr int mod = 998244353;
constexpr int Inf = 1e18;
int n, m;
int Fac[N];
int qpow(int a, int b) {
int res = 1;
while(b) {
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
int inv(int x) {
return qpow(x, mod - 2) % mod;
}
int C(int n, int m) {
return Fac[n] * inv(Fac[m]) % mod * inv(Fac[n - m]) % mod;
}
void F_init() {
Fac[0] = 1;
for (int i = 1; i < N; i ++) {
Fac[i] = (Fac[i - 1] * i) % mod;
}
}
void solve() {
std::cin >> n >> m;
std::cout << C(m, n - 1) * (n - 2) % mod * qpow(2, n - 2) % mod * inv(2) % mod << "\n";
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
F_init();
while (t--) {
solve();
}
return 0;
}