結果
| 問題 |
No.2576 LCM Pattern
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2023-12-04 03:59:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 2,092 ms |
| コンパイル使用メモリ | 198,500 KB |
| 最終ジャッジ日時 | 2025-02-18 07:06:58 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
map<ll,ll> prime_factor(ll x){
map<ll,ll> res;
for(ll i=2;i*i<=x;i++){
while(x%i==0){
res[i]++;
x/=i;
}
}
if(x!=1) res[x]++;
return res;
}
const int MOD=998244353;
ll modpow(ll x,ll n){
x%=MOD;
ll ans=1;
while(n){
if(n&1) ans=ans*x%MOD;
x=x*x%MOD;
n/=2;
}
return ans;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,m;
cin>>n>>m;
map<ll,ll> ma=prime_factor(m);
ll ans=1;
for(auto [a,b]:ma){
ans=ans*(modpow(b+1,n)-modpow(b,n)+MOD)%MOD;
}
cout<<ans<<endl;
return 0;
}
umezo