#line 1 "C_Square.cpp" #include #line 1 "/home/ecasdqina/cpcpp/libs/library_cpp/math/modint.hpp" #line 5 "/home/ecasdqina/cpcpp/libs/library_cpp/math/modint.hpp" namespace cplib { template class modint { using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t; using i32 = std::int_fast32_t; using i64 = std::int_fast64_t; inline u64 apply(i64 x) { return (x < 0 ? x + Modulus : x); }; public: u64 a; static constexpr u64 mod = Modulus; constexpr modint(const i64& x = 0) noexcept: a(apply(x % (i64)Modulus)) {} constexpr modint operator+(const modint& rhs) const noexcept { return modint(*this) += rhs; } constexpr modint operator-(const modint& rhs) const noexcept { return modint(*this) -= rhs; } constexpr modint operator*(const modint& rhs) const noexcept { return modint(*this) *= rhs; } constexpr modint operator/(const modint& rhs) const noexcept { return modint(*this) /= rhs; } constexpr modint operator^(const u64& k) const noexcept { return modint(*this) ^= k; } constexpr modint operator^(const modint& k) const noexcept { return modint(*this) ^= k.value(); } constexpr modint operator-() const noexcept { return modint(Modulus - a); } constexpr modint operator++() noexcept { return (*this) = modint(*this) + 1; } constexpr modint operator--() noexcept { return (*this) = modint(*this) - 1; } const bool operator==(const modint& rhs) const noexcept { return a == rhs.a; }; const bool operator!=(const modint& rhs) const noexcept { return a != rhs.a; }; const bool operator<=(const modint& rhs) const noexcept { return a <= rhs.a; }; const bool operator>=(const modint& rhs) const noexcept { return a >= rhs.a; }; const bool operator<(const modint& rhs) const noexcept { return a < rhs.a; }; const bool operator>(const modint& rhs) const noexcept { return a > rhs.a; }; constexpr modint& operator+=(const modint& rhs) noexcept { a += rhs.a; if (a >= Modulus) a -= Modulus; return *this; } constexpr modint& operator-=(const modint& rhs) noexcept { if (a < rhs.a) a += Modulus; a -= rhs.a; return *this; } constexpr modint& operator*=(const modint& rhs) noexcept { a = a * rhs.a % Modulus; return *this; } constexpr modint& operator/=(modint rhs) noexcept { u64 exp = Modulus - 2; while (exp) { if (exp % 2) (*this) *= rhs; rhs *= rhs; exp /= 2; } return *this; } constexpr modint& operator^=(u64 k) noexcept { auto b = modint(1); while(k) { if(k & 1) b = b * (*this); (*this) *= (*this); k >>= 1; } return (*this) = b; } constexpr modint& operator=(const modint& rhs) noexcept { a = rhs.a; return (*this); } const modint inverse() const { return modint(1) / *this; } const modint power(i64 k) const { if(k < 0) return modint(*this).inverse() ^ (-k); return modint(*this) ^ k; } explicit operator bool() const { return a; } explicit operator u64() const { return a; } constexpr u64& value() noexcept { return a; } constexpr const u64& value() const noexcept { return a; } friend std::ostream& operator<<(std::ostream& os, const modint& p) { return os << p.a; } friend std::istream& operator>>(std::istream& is, modint& p) { u64 t; is >> t; p = modint(t); return is; } }; } #line 4 "C_Square.cpp" using mint = cplib::modint<998244353>; int main() { int n, k; scanf("%d%d", &n, &k); std::vector fact(n + 1, 1), ifact(n + 1); for(int i = 1; i < fact.size(); i++) fact[i] = fact[i - 1] * i; for(int i = 0; i < fact.size(); i++) ifact[i] = fact[i].inverse(); auto comb = [&](int n, int r) -> mint { return fact[n] * ifact[r] * ifact[n - r]; }; auto f = [&](mint x) -> mint { mint ret = 0; for(int i = 2; i <= n; i++) { ret += comb(n, i) * x.power(i) * (-x + k).power(n - i); } return ret; }; mint ans = 0; for(int i = 1; i <= k; i++) { mint count = f(i) - f(i - 1); ans += count * mint(k - i + 1); } printf("%lld\n", ans.value()); }