結果
問題 |
No.2365 Present of good number
|
ユーザー |
👑 ![]() |
提出日時 | 2023-06-30 22:37:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,320 bytes |
コンパイル時間 | 1,107 ms |
コンパイル使用メモリ | 92,052 KB |
最終ジャッジ日時 | 2025-02-15 04:16:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | TLE * 1 -- * 38 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <atcoder/modint> using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<1000000007>; vector<int> pf(int n){ vector<int> res; for(int p=2; p*p<=n; p++){ while(n%p == 0){ res.push_back(p); n /= p; } } if(n != 1) res.push_back(n); return res; } int main(){ i64 N, K; cin >> N >> K; map<int, i64> mp; for(int x : pf(N)) mp[x] += 1; while(K){ if(mp.size() == 1 && mp.begin()->first == 2) break; K--; map<int, i64> buf; for(auto [p,c] : mp) for(int q : pf(p+1)) buf[q] += c; for(auto& q : buf) q.second %= 1000000006; swap(mp, buf); } if(K == 0){ Modint ans = 1; for(auto [p,c] : mp) ans *= Modint(p).pow(c); cout << ans.val(); } else{ i64 q = atcoder::static_modint<1000000006>(2).pow(K/2).pow(mp[2]).val(); K %= 2; if(K % 2 == 0) cout << Modint(2).pow(q).val() << endl; else cout << Modint(3).pow(q).val() << endl; } return 0; }