結果
問題 |
No.2576 LCM Pattern
|
ユーザー |
|
提出日時 | 2024-01-10 20:51:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 194,856 KB |
最終ジャッジ日時 | 2025-02-18 17:03:51 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; const int MOD=998244353; namespace Lib{ ll modpow(long long a,int n){ long long ret=1,t=a; while(n>0){ if(n&1)ret=ret*t%MOD; t=t*t%MOD; n/=2; } return ret; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; vector d(0,0); for(int i=2;i*i<=M;i++){ int cnt=0; while(M%i==0){ cnt+=1; M/=i; } if(cnt>0)d.push_back(cnt); } if(M!=1)d.push_back(1); ll ans=1; for(int i:d){ ans=ans*(Lib::modpow(i+1,N)-Lib::modpow(i,N))%MOD; } if(ans<0)ans+=MOD; cout<<ans<<'\n'; }