結果

問題 No.1659 Product of Divisors
ユーザー otoshigootoshigo
提出日時 2023-02-23 13:12:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,249 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 79,920 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 15:37:22
合計ジャッジ時間 2,074 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const ll MOD=1e9+7;

ll f(ll n,ll k,vector<ll>&inv){
    if(k<0||n<k)return 0;
    ll re=1;
    rep(i,k){
        re*=n-i;
        re%=MOD;
        re*=inv[i+1];
        re%=MOD;
    }
    return re;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin>>N>>K;
    vector<int>V;
    ll b=2;
    while(b*b<=N){
        int cnt=0;
        while(N%b==0){
            N/=b;
            cnt++;
        }
        if(cnt>0)V.push_back(cnt);
        b++;
    }
    if(N>1)V.push_back(1);
    vector<ll>inv(60);
    inv[1]=1;
    for (int i=2;i<60;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    ll ans=1;
    for(auto x:V){
        ll d=0;
        rep(i,x+1){
            d+=f(K+i-1,i,inv);
            d%=MOD;
        }
        ans*=d;
        ans%=MOD;
    }
    cout<<ans<<"\n";
}
0