結果

問題 No.1659 Product of Divisors
ユーザー ktr216
提出日時 2021-08-27 22:39:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 174,192 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 03:43:42
合計ジャッジ時間 2,437 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (ll 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, int> 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, c = 1;
        rep(j, 0, y) {
            c = (c * (x - j)) % MOD;
            c = (c * mod_pow(j + 1, MOD - 2, MOD)) % MOD;
        }
        ans = (ans * c) % MOD;
    }
    cout << ans << endl;
}
0