結果

問題 No.2365 Present of good number
ユーザー 👑 NachiaNachia
提出日時 2023-06-30 22:37:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,320 bytes
コンパイル時間 971 ms
コンパイル使用メモリ 96,580 KB
実行使用メモリ 7,664 KB
最終ジャッジ日時 2023-09-21 16:46:40
合計ジャッジ時間 4,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,608 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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