結果

問題 No.1659 Product of Divisors
ユーザー 👑 KazunKazun
提出日時 2021-07-22 01:31:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,241 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 71,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 00:57:28
合計ジャッジ時間 1,693 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;
using ll=long long;

ll pow_mod(ll a, ll n, ll m){
    if (n==0) return 1;
    else if (n%2==1) return (a*pow_mod(a,n-1,m))%m;
    else{
        ll y=pow_mod(a,n>>1,m);
        return (y*y)%m;
    }
}

ll nCr(ll n, ll r, ll m){
    ll a=1, b=1;
    while (r){
        a=(a*n)%m; b=(b*r)%m;
        n--; r--;
    }
    return (a*pow_mod(b,m-2,m))%m;
}

ll nHr(ll n, ll r, ll m){return nCr((n+r-1)%m,r%m,m);}

vector<pair<ll,ll>> Prime_Factorization(ll N) {
    vector<pair<ll,ll>> R;
    ll e=0;

    while (N%2==0){
        e++;
        N/=2;
    }
    R.push_back({2,e});

    e=0;
    while (N%3==0){
        e++;
        N/=3;
    }
    R.push_back({3,e});

    ll p=5,f=0;
    while (p*p<=N) {
        if (N % p==0){
            ll e=0;
            while (N % p == 0){
                e++;
                N/=p;
            }
            R.push_back({p,e});
        }
        p+=2+2*f;
        f^=1;
    }

    if (N != 1) R.push_back({N, 1});
    return R;
}

int main(){
    ll N,K;
    cin >> N >> K;

    ll Mod=1000000007;
    ll X=1;
    for (auto x:Prime_Factorization(N)){
        ll e=x.second;;
        X*=nHr(K+1,e,Mod);
        X%=Mod;
    }

    cout << X << endl;
}
0