結果

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

ソースコード

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;
}
0