結果

問題 No.2818 A Game I Play to Pass the Time
コンテスト
ユーザー vjudge1
提出日時 2025-10-16 20:24:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,036 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 163,348 KB
実行使用メモリ 15,944 KB
最終ジャッジ日時 2025-10-16 20:24:22
合計ジャッジ時間 6,775 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
const int N=1e6+10;
int n,p[N],k[N],m,s;
int Pow(int a,int b=mod-2){
    int s=1;
    while(b){
        if(b&1)s=s*a%mod;
        a=a*a%mod;b>>=1;
    }
    return s;
}
int C(int n,int m){
    if(n<m)return 0;
    if(m==0)return 1;
    int res=1;
    for(int i=(n-m+1);i<=n;++i)res=res*(i%mod)%mod;
    for(int i=1;i<=m;++i)res=res*Pow(i)%mod;
    return res;
}
void solve(){
    cin>>n>>s;m=0;
    int x=n;
    for(int i=2;i*i<=x;++i)if(x%i==0){
        p[++m]=i;while(x%i==0)++k[m],x/=i;
    }
    if(x!=1)p[++m]=x,k[m]=1;
    int ans=1;
    for(int i=1;i<=m;++i){
        int val=0;
        for(int j=0;j<=k[i];++j){
            val=(val+Pow(p[i],k[i]-j)%mod*C(s-2+j,j)%mod)%mod;
        }
        ans=ans*val%mod;
    }
    ans=ans*(s%mod)%mod;
    cout<<ans<<'\n';
    return ;
}//????
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int T;cin>>T;while(T--)solve();
    return 0;
}
/* 
1
1000000000000000000
1
*/
0