結果

問題 No.2818 A Game I Play to Pass the Time
ユーザー Caiiiiiiii
提出日時 2024-08-18 15:03:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 769 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 192,512 KB
最終ジャッジ日時 2025-02-23 23:07:02
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other RE * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |   scanf("%lld%lld", &n, &s);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:40:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |   scanf("%d", &cases);
      |   ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using LL = long long;

const int N = 67;
const int MOD = 998244353;

int inv[N];

void solve() {
  LL n, s;
  scanf("%lld%lld", &n, &s);
  int ans = s % MOD;
  for(int i = 2; i <= 100; ++i)
    if(n % i == 0) {
      LL mul = 1;
      int tmp = 0, cnt = 0;
      while(n % i == 0) {
	++cnt;
	n /= i;
	mul *= i;
      }
      for(int j = 0, c = 1; j <= tmp; ++j) {
	tmp = (tmp + mul % MOD * c) % MOD;
	c = 1LL * c * (s + j - 1) % MOD * inv[j + 1] % MOD;
	mul /= i;
      }
      ans = 1LL * ans * tmp % MOD;
    }
  printf("%d\n", ans);
}

int main() {

  inv[1] = 1;
  for(int i = 2; i < N; ++i)
    inv[i] = (MOD - 1LL * MOD / i * inv[MOD % i]) % MOD;
  
  int cases = 1;
  scanf("%d", &cases);

  while(cases--)
    solve();

  return 0;

}
0