結果
| 問題 |
No.2818 A Game I Play to Pass the Time
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-19 13:50:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 525 ms / 2,000 ms |
| コード長 | 1,807 bytes |
| コンパイル時間 | 2,251 ms |
| コンパイル使用メモリ | 204,116 KB |
| 最終ジャッジ日時 | 2025-02-23 16:15:23 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
ll modpow(ll A,ll N){
ll res=1;
while(N){
if(N&1) res=res*A%mod;
A=A*A%mod;
N>>=1;
}
return res;
}
ll modinv(ll A){return modpow(A,mod-2);}
int main() {
faster;
vector<ll> P;
for(ll i=2;i<=100;i++){
bool ok=true;
for(ll j=2;j<i;j++){
if(i%j==0) ok=false;
}
if(ok) P.push_back(i);
}
vector<vector<ll>> Q(25,vector<ll>(100,1));
rep(i,25){
rep(j,100-1){
Q[i][j+1]=Q[i][j];
Q[i][j+1]*=P[i];
Q[i][j+1]%=mod;
}
}
vector<ll> inv(100);
rep(i,100) inv[i]=modinv(i);
ll T;
cin >> T;
while(T--){
ll X,N;
cin >> X >> N;
vector<ll> R(100,1);
rep(i,100-1){
R[i+1]=R[i];
R[i+1]*=((N+i-1)%mod);
R[i+1]%=mod;
R[i+1]*=inv[i+1];
R[i+1]%=mod;
}
ll loop=1;
vector<ll> A(25,0);
rep(i,25){
while(X%P[i]==0){
A[i]++;
X/=P[i];
}
loop*=(A[i]+1);
}
ll ans=N%mod;
rep(i,25){
ll cnt=0;
rep(j,A[i]+1){
ll now=1;
now*=Q[i][j];
now*=R[A[i]-j];
cnt+=now;
cnt%=mod;
}
ans*=cnt;
ans%=mod;
}
cout << ans << '\n';
}
return 0;
}