use proconio::{fastout, input}; #[fastout] fn main() { input! {n:usize,mut k:usize} if 2 * k > n { k = n - k; } let mut ans = ModInt::::new(1); for i in 1..=k { ans *= ModInt::new(n - i + 1) / ModInt::new(i); } println!("{}", ans); } const MOD: usize = 998244353; use std::fmt; use std::ops; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct ModInt { val: usize, } impl fmt::Display for ModInt { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.val) } } impl ModInt { pub fn new(n: usize) -> Self { Self { val: n % MOD } } pub fn val(&self) -> usize { // 念のためMOD演算 self.val % MOD } pub fn _set_val(&mut self, val: usize) { self.val = val % MOD; } pub fn pow_u(&self, mut n: usize) -> Self { let mut val = self.val; let mut res: usize = 1; while n > 0 { if n % 2 == 1 { res = (res * val) % MOD; } val = (val * val) % MOD; n /= 2; } Self { val: res } } pub fn pow(&self, other: Self) -> Self { self.pow_u(other.val) } pub fn inv(&self) -> Self { self.pow_u(MOD - 2) } } impl ops::Add for ModInt { type Output = Self; fn add(self, other: Self) -> Self { Self { val: (self.val + other.val) % MOD, } } } impl ops::AddAssign for ModInt { fn add_assign(&mut self, other: Self) { *self = Self { val: (self.val + other.val) % MOD, }; } } impl ops::Mul for ModInt { type Output = Self; fn mul(self, other: Self) -> Self { Self { val: (self.val * other.val) % MOD, } } } impl ops::MulAssign for ModInt { fn mul_assign(&mut self, other: Self) { *self = Self { val: (self.val * other.val) % MOD, }; } } impl ops::Sub for ModInt { type Output = Self; fn sub(mut self, other: Self) -> Self { if self.val < other.val { self.val += MOD; } Self { val: self.val - other.val % MOD, } } } impl ops::SubAssign for ModInt { fn sub_assign(&mut self, other: Self) { if self.val < other.val { self.val += MOD; } *self = Self { val: (self.val - other.val) % MOD, }; } } impl ops::Div for ModInt { type Output = Self; fn div(self, other: Self) -> Self { if other.val == 0 { panic!("0 division occured."); } self * other.inv() } } impl ops::DivAssign for ModInt { fn div_assign(&mut self, other: Self) { if other.val == 0 { panic!("0 division occured."); } *self *= other.inv(); } } pub struct ModCom { fac: Vec, finv: Vec, } impl ModCom { pub fn new(cap: usize) -> Self { let mut fac = vec![0; cap]; let mut finv = vec![0; cap]; let mut inv = vec![0; cap]; fac[0] = 1; fac[1] = 1; finv[0] = 1; finv[1] = 1; inv[1] = 1; for i in 2..cap { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } Self { fac, finv } } pub fn com(&self, n: usize, k: usize) -> usize { if n < k { return 0; } self.fac[n] * (self.finv[k] * self.finv[n - k] % MOD) % MOD } }