#![allow(dead_code, unused_mut)] #![allow(non_snake_case)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } struct Combination { MOD: u64, size: usize, fact: Vec, inv_fact: Vec, } impl Combination { fn new(size: usize, _MOD: u64) -> Self { let mut fact = vec![1; size + 1]; let mut inv_fact = vec![1; size + 1]; for i in 1..size + 1 { fact[i] = fact[i - 1] * i as u64 % _MOD; } inv_fact[size] = Self::modpow(fact[size], _MOD - 2, _MOD); for i in (1..size + 1).rev() { inv_fact[i - 1] = inv_fact[i] * i as u64 % _MOD; } Combination { MOD: _MOD, size, fact, inv_fact, } } fn modpow(mut x: u64, mut y: u64, m: u64) -> u64 { let mut res: u64 = 1; while y > 0 { if y & 1 > 0 { res = res * x % m; } x = x * x % m; y >>= 1; } res } fn modinv(x: u64, m: u64) -> u64 { Self::modpow(x, m - 2, m) } fn nPr(&self, n: usize, r: usize) -> u64 { if n < r { return 0; }; self.fact[n] * self.inv_fact[n - r] % self.MOD } fn nCr(&self, n: usize, r: usize) -> u64 { if n < r { return 0; }; self.fact[n] * self.inv_fact[r] % self.MOD * self.inv_fact[n - r] % self.MOD } } const MOD: u64 = 998244353; fn main() { input!{ n:usize, m:usize, a:usize, b:usize } let ncr = Combination::new(m + n + 1, MOD); let mut ans = 0; let t = (n - 1) * a; for s in 1..m+1 { let l = std::cmp::min(s + b, m); if l - s < t { break; } // println!("{} {}", l -s-t+n, n); ans = (ans + ncr.nCr(l - s - t + n - 1, n - 1)) % MOD; } println!("{}", ans * ncr.fact[n] % MOD); }