結果

問題 No.2818 A Game I Play to Pass the Time
ユーザー NachiaNachia
提出日時 2024-07-19 22:53:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 1,840 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 100,040 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 22:53:48
合計ジャッジ時間 12,940 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 472 ms
5,376 KB
testcase_02 AC 462 ms
5,376 KB
testcase_03 AC 438 ms
5,376 KB
testcase_04 AC 426 ms
5,376 KB
testcase_05 AC 453 ms
5,376 KB
testcase_06 AC 413 ms
5,376 KB
testcase_07 AC 421 ms
5,376 KB
testcase_08 AC 452 ms
5,376 KB
testcase_09 AC 438 ms
5,376 KB
testcase_10 AC 453 ms
5,376 KB
testcase_11 AC 436 ms
5,376 KB
testcase_12 AC 420 ms
5,376 KB
testcase_13 AC 420 ms
5,376 KB
testcase_14 AC 424 ms
5,376 KB
testcase_15 AC 447 ms
5,376 KB
testcase_16 AC 430 ms
5,376 KB
testcase_17 AC 416 ms
5,376 KB
testcase_18 AC 421 ms
5,376 KB
testcase_19 AC 406 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <array>
#include <cmath>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
#define repr(i,n) for(int i=int(n)-1; i>=0; i--)
const i64 INF = 1001001001001001001;
const char* yn(bool x){ return x ? "Yes" : "No"; }
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
template<typename A> using nega_queue = std::priority_queue<A,std::vector<A>,std::greater<A>>;
template<class R> auto ComparingBy(R f){ return [g=std::move(f)](auto l, auto r) -> bool { return g(l) < g(r); }; }
#include <atcoder/modint>
using Modint = atcoder::static_modint<998244353>;
using namespace std;

void testcase(){
    i64 Z = 64;
    int T; cin >> T;
    i64 primes[] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 };
    vector<Modint> Inv(Z+1);
    for(int i=1; i<=Z; i++) Inv[i] = Modint(i).inv();
    rep(t,T){
        i64 N, S; cin >> N >> S;
        vector<i64> F(25);
        rep(i,25) while(N % primes[i] == 0){ N /= primes[i]; F[i]++; }
        vector<Modint> comb(Z+1);
        comb[0] = 1;
        for(int i=1; i<=Z; i++) comb[i] = comb[i-1] * (S + i - 2) * Inv[i];
        Modint ans = 1;
        rep(i,25) if(F[i]){
            Modint p = primes[i];
            Modint pp = 1;
            Modint t = 0;
            rep(k,F[i]+1){
                t += pp * comb[F[i]-k];
                pp *= p;
            }
            ans *= t;
        }
        ans *= S;
        cout << ans.val() << '\n';
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    testcase();
    return 0;
}
0