結果
| 問題 |
No.2818 A Game I Play to Pass the Time
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-10-16 20:19:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 993 bytes |
| コンパイル時間 | 1,714 ms |
| コンパイル使用メモリ | 163,484 KB |
| 実行使用メモリ | 12,948 KB |
| 最終ジャッジ日時 | 2025-10-16 20:20:06 |
| 合計ジャッジ時間 | 9,156 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 18 |
ソースコード
#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;
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;
}
vjudge1