結果
| 問題 |
No.2818 A Game I Play to Pass the Time
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-19 13:42:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,773 bytes |
| コンパイル時間 | 2,301 ms |
| コンパイル使用メモリ | 203,388 KB |
| 最終ジャッジ日時 | 2025-02-23 16:14:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 18 |
ソースコード
#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() {
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;
}
}
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]*=modinv(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=0;
rep(LOOP,loop){
ll Y=LOOP;
ll Z=N;
rep(i,25){
Z*=Q[i][(Y%(A[i]+1))];
Z%=mod;
Z*=R[A[i]-(Y%(A[i]+1))];
Z%=mod;
Y/=(A[i]+1);
}
ans+=Z;
ans%=mod;
}
cout << ans << endl;
}
return 0;
}