結果

問題 No.1659 Product of Divisors
ユーザー ktr216
提出日時 2021-08-27 22:23:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 173,624 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-21 03:20:25
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 8
権限があれば一括ダウンロードができます

ソースコード

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