結果

問題 No.2818 A Game I Play to Pass the Time
ユーザー highlighterhighlighter
提出日時 2024-04-25 23:20:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 1,606 bytes
コンパイル時間 6,833 ms
コンパイル使用メモリ 336,520 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 21:01:25
合計ジャッジ時間 25,041 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 553 ms
5,248 KB
testcase_02 AC 517 ms
5,376 KB
testcase_03 AC 511 ms
5,376 KB
testcase_04 AC 503 ms
5,376 KB
testcase_05 AC 510 ms
5,376 KB
testcase_06 AC 500 ms
5,376 KB
testcase_07 AC 501 ms
5,376 KB
testcase_08 AC 500 ms
5,376 KB
testcase_09 AC 496 ms
5,376 KB
testcase_10 AC 498 ms
5,376 KB
testcase_11 AC 385 ms
5,376 KB
testcase_12 AC 250 ms
5,376 KB
testcase_13 AC 329 ms
5,376 KB
testcase_14 AC 417 ms
5,376 KB
testcase_15 AC 402 ms
5,376 KB
testcase_16 AC 403 ms
5,376 KB
testcase_17 AC 362 ms
5,376 KB
testcase_18 AC 362 ms
5,376 KB
testcase_19 AC 448 ms
5,376 KB
testcase_20 AC 427 ms
5,376 KB
testcase_21 AC 459 ms
5,376 KB
testcase_22 AC 325 ms
5,376 KB
testcase_23 AC 309 ms
5,376 KB
testcase_24 AC 312 ms
5,376 KB
testcase_25 AC 296 ms
5,376 KB
testcase_26 AC 434 ms
5,376 KB
testcase_27 AC 447 ms
5,376 KB
testcase_28 AC 383 ms
5,376 KB
testcase_29 AC 390 ms
5,376 KB
testcase_30 AC 394 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using mint=modint998244353;

int prime[100]={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,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541};

vector<pair<int,int>> factorize(long long N,long long M){
    vector<pair<int,int>> vec;
    for(int i=0;i<M;i++){
        int count=0;
        while(N%prime[i]==0){
            N/=prime[i];
            count++;
        }
        vec.push_back(make_pair(prime[i],count));
    }
    return vec;
}

int main(){
    long long M,Q;
	scanf("%lld%lld",&M,&Q);
    mint inv[61];
    inv[1]=1;
    for(int i=2;i<61;i++){
        inv[i]=-inv[998244353%i]*mint(998244353/i);
    }
    for(;Q--;){
        long long N,S;
		scanf("%lld%lld",&N,&S);
        vector<pair<int,int>> vec=factorize(N,M);
        mint ans=1;
        for(auto p : vec){
            vector<mint> data(p.second+1);
            data[0]=1;
            for(int i=1;i<=p.second;i++){
                data[i]=data[i-1]*mint(p.first);
            }
            mint res=data[p.second];
            mint mem=1;
            for(int i=1;i<=p.second;i++){
                mem*=inv[i]*mint(S-2+i);
                res+=data[p.second-i]*mem;
            }
            ans*=res;
        }
        ans*=mint(S);
		printf("%d\n",ans.val());
    }
}
0