結果
問題 | No.2818 A Game I Play to Pass the Time |
ユーザー |
|
提出日時 | 2024-07-19 13:49:20 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,740 bytes |
コンパイル時間 | 2,339 ms |
コンパイル使用メモリ | 210,264 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-07-19 13:49:28 |
合計ジャッジ時間 | 8,387 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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=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 << endl; } return 0; }