/* -*- coding: utf-8 -*- * * 2896.cc: No.2896 Monotonic Prime Factors - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_A = 320; const int MAX_N = MAX_A * 18; const int MOD = 998244353; /* typedef */ using vb = vector; using vi = vector; template struct MI { int v; MI(): v() {} MI(int _v): v(_v % MOD) { if (v < 0) v += MOD; } MI(long long _v): v(_v % MOD) { if (v < 0) v += MOD; } explicit operator int() const { return v; } MI operator+(const MI m) const { return MI(v + m.v); } MI operator-(const MI m) const { return MI(v + MOD - m.v); } MI operator*(const MI m) const { return MI((long long)v * m.v); } MI &operator+=(const MI m) { return (*this = *this + m); } MI &operator-=(const MI m) { return (*this = *this - m); } MI &operator*=(const MI m) { return (*this = *this * m); } bool operator==(const MI m) const { return v == m.v; } bool operator!=(const MI m) const { return v != m.v; } MI pow(int n) const { // a^n % MOD MI pm = 1, a = *this; while (n > 0) { if (n & 1) pm *= a; a *= a; n >>= 1; } return pm; } MI inv() const { return pow(MOD - 2); } MI operator/(const MI m) const { return *this * m.inv(); } MI &operator/=(const MI m) { return (*this = *this / m); } }; using mi = MI; using vmi = vector; /* global variables */ vb primes; vi pnums; vmi fs, invfs; /* subroutines */ int gen_primes(int maxp) { primes.assign(maxp + 1, true); primes[0] = primes[1] = false; int p; for (p = 2; p * p <= maxp; p++) if (primes[p]) { pnums.push_back(p); for (int q = p * p; q <= maxp; q += p) primes[q] = false; } for (; p <= maxp; p++) if (primes[p]) pnums.push_back(p); return (int)pnums.size(); } int pdnum(int n) { int sum = 0; for (auto pi: pnums) { if (pi * pi > n) { if (n > 1) sum++; return sum; } while (n % pi == 0) n /= pi, sum++; } return -1; } inline mi nck(int n, int k) { // nCk % MOD if (n < k || k < 0) return 0; return fs[n] * invfs[n - k] * invfs[k]; } inline mi nhk(int n, int k) { // nHk % MOD if (n < 0 || k < 0) return 0; return nck(n + k - 1, k); } void prepare_fracs(int n) { fs.resize(n + 1), invfs.resize(n + 1); fs[0] = invfs[0] = 1; for (int i = 1; i <= n; i++) { fs[i] = fs[i - 1] * i; invfs[i] = fs[i].inv(); } } /* main */ int main() { gen_primes(MAX_A); prepare_fracs(MAX_N); int qn; scanf("%d", &qn); int l = 0; while (qn--) { int a, b; scanf("%d%d", &a, &b); l += pdnum(a); mi c = nhk(b, l - b); printf("%d\n", (int)c); } return 0; }