結果
問題 | No.2576 LCM Pattern |
ユーザー |
|
提出日時 | 2023-12-13 21:07:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 1,628 ms |
コンパイル使用メモリ | 170,812 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 05:31:11 |
合計ジャッジ時間 | 2,184 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function 'll power(ll, ll)': main.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type] 45 | } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<n; i++) #define debug 0 #define YES cout << "Yes" << endl; #define NO cout << "No" << endl; using ll = long long; using ld = long double; const int mod = 998244353; const int MOD = 1000000007; const double pi = atan2(0, -1); #include <time.h> #include <chrono> void func(vector<ll> &exp, vector<ll> &prime, ll M) { for (ll i = 2; i <= sqrt(M); i++) { if (M % i == 0) { prime.push_back(i); ll c = 0; while (M % i == 0) { M /= i; c++; } exp.push_back(c); } } if (M > 1) { prime.push_back(M); exp.push_back(1); } } ll power(ll p, ll a) { if (a == 0) { return 1LL; } if (a % 2 == 1) { return (p * power(p, a - 1)) % mod; } if (a % 2 == 0) { ll t = power(p, a / 2) % mod; return (t * t)%mod; } } int main() { ll N, M; cin >> N >> M; vector<ll> exp, prime; func(exp, prime, M); ll ans = 1; rep(i, prime.size()) { ans *= (mod + power(exp[i] + 1, N) - power(exp[i], N)) % mod; ans %= mod; } cout << ans << endl; }