結果

問題 No.2365 Present of good number
ユーザー momoyuumomoyuu
提出日時 2023-10-25 15:35:10
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,027 bytes
コンパイル時間 2,889 ms
コンパイル使用メモリ 247,316 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 15:35:16
合計ジャッジ時間 5,072 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#include<atcoder/modint>
using mint = atcoder::modint1000000007;


ll modpow(ll n,ll k,ll mod){
    ll res = 1;
    while(k){
        if(k&1) res = (res*n)%mod;
        n = (n*n)%mod;
        k>>=1;
    }
    return res%mod;
}

mint calc(ll n,ll a,ll k){
    if(k==0) return mint(n).pow(a);
    if(n==2){
        ll can = k >> 1;
        const ll use = 1000000006;
        ll c = modpow(2,can,use);
        c = (c*a) % use;
        if(k&1) return mint(3).pow(c);
        else return mint(2).pow(c);
    }
    ll m = n + 1;
    mint res = 1;
    while(m%2==0){
        res *= calc(2,a,k-1);
        m /= 2; 
    }
    if(m!=1) res *= calc(m,a,k-1);
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 

    ll n,k;
    cin>>n>>k;
    mint ans = 1;
    for(int i = 2;i<=n;i++){
        if(n%i!=0) continue;
        while(n%i==0){
            ans *= calc(i,1,k);
            n /= i;
        }
    }
    cout<<ans.val()<<endl;
}
0