結果

問題 No.2576 LCM Pattern
ユーザー Naru820
提出日時 2025-05-07 18:59:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 3,375 ms
コンパイル使用メモリ 278,300 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-07 18:59:42
合計ジャッジ時間 4,209 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 998244353;

ll n,m,ans = 1;
ll power(ll base,ll exp){
  if(exp == 0) return 1;
  ll ret = power(base,exp / 2);
  ret = ret * ret % mod;
  if(exp % 2) ret = (ret * (base % mod)) % mod;
  return ret;
}
int main(){
  cin >> n >> m;
  vector<int> a;
  for(int i = 2; i * i <= m; i++){
    if(m % i == 0){
      int cnt = 0;
      while(m % i == 0){
        m /= i;
        cnt++;
      }
      a.emplace_back(cnt);
    }
  }
  if(m > 1) a.emplace_back(1);
  for(auto &x: a){
    ll p = power(x + 1,n) - power(x,n);
    p = p % mod;
    ans = ans * p % mod;
  }
  cout << (ans + mod) % mod;
}
0