結果

問題 No.1659 Product of Divisors
ユーザー aut_jul_duraut_jul_dur
提出日時 2021-08-27 21:35:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 2,718 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 232,596 KB
実行使用メモリ 15,848 KB
最終ジャッジ日時 2023-08-13 08:11:03
合計ジャッジ時間 6,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
15,644 KB
testcase_01 AC 56 ms
15,520 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 55 ms
15,608 KB
testcase_04 AC 55 ms
15,708 KB
testcase_05 AC 56 ms
15,580 KB
testcase_06 AC 55 ms
15,484 KB
testcase_07 AC 56 ms
15,792 KB
testcase_08 AC 55 ms
15,544 KB
testcase_09 AC 56 ms
15,848 KB
testcase_10 AC 56 ms
15,576 KB
testcase_11 AC 56 ms
15,488 KB
testcase_12 AC 56 ms
15,520 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 56 ms
15,600 KB
testcase_15 AC 55 ms
15,580 KB
testcase_16 AC 56 ms
15,480 KB
testcase_17 AC 56 ms
15,476 KB
testcase_18 AC 55 ms
15,636 KB
testcase_19 AC 56 ms
15,712 KB
testcase_20 AC 56 ms
15,484 KB
testcase_21 AC 56 ms
15,480 KB
testcase_22 AC 56 ms
15,716 KB
testcase_23 AC 57 ms
15,612 KB
testcase_24 AC 56 ms
15,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 9*1e18;
using ll = long long;
using mint = modint1000000007;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
long double PI = 3.14159265358979;

ll fac[510000], finv[510000], inv[510000];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<ll> primelist;

bool Prime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

void primeinput(){
  for(ll i = 2;i<200200;i++){
    if(Prime(i)){
      primelist.push_back(i);
    }
  }
}

vector <ll> bunkai(ll N){
  vector <ll> res;
  rep(i,primelist.size()){
    while(N%primelist[i] == 0){
      res.push_back(primelist[i]);
      N/=primelist[i];
    }
  }
  if(N!=1){
    res.push_back(N);
  }
  return res;
}

long long pow(long long x, long long n, long long MM) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MM;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MM;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}



mint comb(ll N,ll K){
  mint t = 1;
  for(int i = 0;i<K;i++){
    t *= N;
    N--;
  }
  ll te = K;
  for(int i = 0;i<K;i++){
    t /= te;
    te--;
  }
  return t;
}
  




int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll N,K;
  cin>>N>>K;
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  primeinput();
  COMinit();
  vector<ll> S = bunkai(N);
  sort(all(S));
  vector<ll> num;
  ll temp = 1;
  for(int i = 1;i<S.size();i++){
    if(S[i] == S[i-1]){
      temp++;
    }
    else{
      num.push_back(temp);
      temp = 1;
    }
  }
  num.push_back(temp);
  mint ans = 1;
  rep(i,num.size()){
    ll T = num[i];
    mint temp = 0;
    for(int k = 0;k<=T;k++){
      temp += comb(K+k-1,k);
    }
    ans *= temp;
  }
  cout << ans.val() << endl;
  return 0;
}
0