結果

問題 No.2896 Monotonic Prime Factors
ユーザー vjudge1
提出日時 2024-09-25 14:48:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 78,080 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-09-25 14:48:36
合計ジャッジ時間 4,650 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

const int MAXN = 1e5 + 5, MAXV = 2e6 + 3, Mod = 998244353;

int T, c, fac[MAXV] = {1, 1}, inv[MAXV] = {0, 1}, facinv[MAXV] = {1, 1};

int C(int n, int m) {
  if (n < m) return 0;
  return 1ll * fac[n] * facinv[m] % Mod * facinv[n - m] % Mod;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  for (int i = 2; i < MAXV; i++) {
    fac[i] = 1ll * fac[i - 1] * i % Mod;
    inv[i] = 1ll * (Mod - Mod / i) * inv[Mod % i] % Mod;
    facinv[i] = 1ll * facinv[i - 1] * inv[i] % Mod;
  }
  cin >> T;
  for (int x, n; T--; ) {
    cin >> x >> n;
    for (int i = 2, t = x; i * i <= t; i++) {
      for (; x % i == 0; x /= i) {
        c++;
      }
    }
    c += (x > 1);
    cout << C(c - 1, n - 1) << '\n';
  }
  return 0;
}
0