結果

問題 No.1659 Product of Divisors
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-07 23:25:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,230 bytes
コンパイル時間 1,110 ms
コンパイル使用メモリ 114,492 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 19:17:00
合計ジャッジ時間 2,862 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>

using namespace std;

using ll = long long;
const ll modc=1e9+7, MAX=1000000;
vector<ll> f, finv;

ll inv(ll x){
    ll ans = 1, e = modc-2;
    x %= modc;

    while (e > 0){
        if ((e & 1LL)) ans = (ans * x) % modc;
        e = e >> 1LL;
        x = (x*x) % modc;
    }

    return ans;
}

ll C(ll n, ll k){
    ll ans=1;
 
    for(ll i = 0; i<k; i++) ans = ans * (n-i) % modc;

    for(ll i=1; i<=k; i++) ans = (ans*inv(i)) % modc;
 
    return ans;
}

map<ll, ll> prime;

void prime_factor(ll n){
    ll m = n;

    if (n % 2 == 0){
        while(n % 2 == 0){
            prime[2]++;
            n /= 2;
        }
    }

    for (ll i = 3; i*i <= m; i+=2){
        if (n % i == 0){
            while(n % i == 0){
                prime[i]++;
                n /= i;
            }
        }
    }

    if (n != 1){
        prime[n]++;
    }
}

int main(){

    ll N, K, ans=1;
    cin >> N >> K;
    prime_factor(N);
    for (auto [x, y] : prime){
        ans *= C(K+y, y);
        ans %= modc;
    }

    cout << ans << endl;

    return 0;
}
0