結果

問題 No.1659 Product of Divisors
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2021-08-27 22:11:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 167,748 KB
実行使用メモリ 10,140 KB
最終ジャッジ日時 2024-05-01 02:47:40
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mpow(ll a, ll n, ll m = 1e9 + 7) {
    ll ret = 1;
    while (n) {
        if (n % 2) {
            ret *= a;
            ret %= m;
        }
        a = (a * a) % m;
        n /= 2;
    }
    return ret;
}
int main () {
    ll N, K;
    ll m = 1e9 + 7;
    cin >> N >> K;
    ll cmb[66];
    cmb[0] = 1;
    for (int i = 1; i < 66; i ++) {
        cmb[i] *= (K + i);
        cmb[i] %= m;
        cmb[i] *= mpow(i, m - 2);
        cmb[i] %= m;
    }
    ll N_ = N;
    ll ans = 1;
    for (int i = 2; i * i <= N_; i ++) {
        if (N == 1) {
            break;
        }
        if (N % i == 0) {
            int cnt = 0;
            while (N % i == 0) {
                cnt ++;
                N /= i;
            }
            ans *= cmb[cnt];
            ans %= m;
        }
    }
    if (N > 1) {
        cout << K + 1 << endl;
    } else {
        cout << ans << endl;
    }
}
0