結果

問題 No.1659 Product of Divisors
ユーザー ktr216ktr216
提出日時 2021-08-27 22:23:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 174,860 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 03:02:58
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    map<ll, ll> mp;
    for (ll i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            mp[i]++;
            N /= i;
            //cout << N << " " << i << " " << mp[i] << endl;
        }
    }
    if (N > 1) mp[N]++;
    ll ans = 1, MOD = 1e9 + 7;
    for (auto i : mp) {
        //cout << i.first << " " << i.second << endl;
        ll y = i.second, x = K + y;
        rep(j, 0, y) {
            ans = (ans * (x - j)) % MOD;
            ans = (ans * mod_pow(j + 1, MOD - 2, MOD)) % MOD;
        }
    }
    cout << ans << endl;
}
0