結果

問題 No.2365 Present of good number
ユーザー logxlogx
提出日時 2021-06-29 23:04:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 3,624 bytes
コンパイル時間 3,949 ms
コンパイル使用メモリ 205,376 KB
実行使用メモリ 27,324 KB
最終ジャッジ日時 2023-09-21 14:39:49
合計ジャッジ時間 6,051 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
27,280 KB
testcase_01 AC 24 ms
26,724 KB
testcase_02 AC 24 ms
26,732 KB
testcase_03 AC 24 ms
26,704 KB
testcase_04 AC 25 ms
27,276 KB
testcase_05 AC 24 ms
27,016 KB
testcase_06 AC 24 ms
27,016 KB
testcase_07 AC 24 ms
27,112 KB
testcase_08 AC 24 ms
27,284 KB
testcase_09 AC 25 ms
27,140 KB
testcase_10 AC 25 ms
27,072 KB
testcase_11 AC 25 ms
26,728 KB
testcase_12 AC 24 ms
27,020 KB
testcase_13 AC 24 ms
26,704 KB
testcase_14 AC 25 ms
27,036 KB
testcase_15 AC 24 ms
27,284 KB
testcase_16 AC 25 ms
26,724 KB
testcase_17 AC 25 ms
27,088 KB
testcase_18 AC 25 ms
26,736 KB
testcase_19 AC 25 ms
27,116 KB
testcase_20 AC 26 ms
27,040 KB
testcase_21 AC 25 ms
27,096 KB
testcase_22 AC 25 ms
27,100 KB
testcase_23 AC 25 ms
27,072 KB
testcase_24 AC 25 ms
26,708 KB
testcase_25 AC 25 ms
27,168 KB
testcase_26 AC 25 ms
26,712 KB
testcase_27 AC 25 ms
27,016 KB
testcase_28 AC 25 ms
27,020 KB
testcase_29 AC 25 ms
27,168 KB
testcase_30 AC 25 ms
27,024 KB
testcase_31 AC 24 ms
27,040 KB
testcase_32 AC 24 ms
27,008 KB
testcase_33 AC 25 ms
27,068 KB
testcase_34 AC 24 ms
26,736 KB
testcase_35 AC 25 ms
27,020 KB
testcase_36 AC 26 ms
27,020 KB
testcase_37 AC 25 ms
27,100 KB
testcase_38 AC 26 ms
26,708 KB
testcase_39 AC 26 ms
27,172 KB
testcase_40 AC 26 ms
27,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOGX
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
//using namespace atcoder;
using mint=atcoder::modint1000000007;

/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)

/*---------type/const---------*/
const int big=1000000007;
//const int big=998244353;
const double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char newl='\n';
struct{
    constexpr operator int(){return -int(1e9)-10;}
    constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
    constexpr operator int(){return int(1e9)+10;}
    constexpr operator ll(){return ll(1e18)+10;}
    constexpr auto operator -(){return neginf;}
}inf;

/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif

/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}



int main(){
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    std::cout.precision(10);
/*------------------------------------*/
    
    int n;
    ll K;
    cin >> n >> K;
    //2の冪 * 3の冪 になるまでの操作回数は O(log{N})くらい。
    const int max_prime=100000;
    const int sz=60;
    vector<vector<int>> dp(sz,vector<int>(max_prime));
    {
        int N=n;
        for(int i=2;i*i<=n;i++){
            while(N%i==0){
                dp[0][i]++;
                N/=i;
            }
        }
        if(N>1)dp[0][N]++;
    }
    rep(i,sz-1){
        for(int j=2;j<max_prime;j++)if(dp[i][j]){
            //j+1の素因数分解
            int now=j+1;
            for(int k=2;k*k<=now;k++){
                while(now%k==0){
                    dp[i+1][k]+=dp[i][j], dp[i+1][k]%=big-1;
                    now/=k;
                }
            }
            if(now>1)dp[i+1][now]+=dp[i][j], dp[i+1][now]%=big-1;
        }
    }
    if(K<sz){
        mint ans=1;
        for(int j=2;j<max_prime;j++)ans*=mint(j).pow(dp[K][j]);
        cout << ans.val() << newl;
    }
    else{
        K-=sz-1;
        //2->3 : 個数は固定
        //3->2 : 個数は2倍
        //2回の操作でどちらも2倍になる。
        //最終的にmod(1e9+7)で計算するので、mod(1e9+6)で個数を数える。
        ll res[]={dp.back()[2]*expm(2LL,K/2,big-1) % (big-1), dp.back()[3]*expm(2LL,K/2,big-1) % (big-1)};
        if(K&1){
            swap(res[0],res[1]);
            res[0]*=2;
        }
        mint ans=mint(2).pow(res[0]) * mint(3).pow(res[1]);
        cout << ans.val() << newl;
    }
}
0