結果
| 問題 | No.2576 LCM Pattern | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-09 00:42:29 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 994 bytes | 
| コンパイル時間 | 1,624 ms | 
| コンパイル使用メモリ | 175,060 KB | 
| 実行使用メモリ | 10,624 KB | 
| 最終ジャッジ日時 | 2024-09-27 03:20:57 | 
| 合計ジャッジ時間 | 6,080 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 6 TLE * 1 -- * 16 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
const int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}}
int inv(int x) {return po(x,p-2);}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;cin>>n>>m;
    vector<int> divs;
    for(int i=1;i<=m;++i)
    {
        if(m%i==0)
        {
            divs.push_back(i);divs.push_back(m/i);
        }
    }
    sort(all(divs));divs.erase(unique(all(divs)),divs.end());
    vector<int> res(divs.size());fill(all(res),0LL);
    int cnt[divs.size()]={0};
    for(int i=0;i<divs.size();++i)
    {
        for(int j=0;j<i;++j)
        {
            if(divs[i]%divs[j]==0) {
            cnt[i]++;res[i]-=res[j];res[i]%=p;
            }
        }
        res[i]+=po(cnt[i]+1,n);res[i]%=p;
    }
    cout<<(res[divs.size()-1]%p+p)%p;
    return 0;
}
            
            
            
        