結果

問題 No.847 Divisors of Power
ユーザー magmag
提出日時 2020-08-15 03:14:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 1,888 ms
コンパイル使用メモリ 173,152 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 23:34:37
合計ジャッジ時間 3,007 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repe(i,a)for(auto &i:a)

void in(){} template<typename Head,typename... Tail> void in(Head&& head,Tail&&... tail){cin>>head;in(forward<Tail>(tail)...);}

//N^Kの正の約数
//n^k=n*n...*n(k);
map<ll,ll> enumpr(ll n) {
  map<ll,ll> V;
  for(ll i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
  if(n>1) V[n]++;
  return V;
}
ll fastpow(ll x, ll n) {
  ll ret = 1;
  while (0 < n) {
    if ((n % 2) == 0) x *= x, n >>= 1;
    else ret *= x, --n;
  }
  return ret;
}
ll n,k,m;
//候補を決定
vector<pair<ll, ll>> primes;
int dfs(ll cu, ll tot) {
  if(cu == primes.size()) return 1;
  ll res = 0;
  rep2(cnt, 0, primes[cu].second + 1) {
    ll tot2 = tot * fastpow(primes[cu].first, cnt);
    //M 以下のものの個数
    if(m < tot2) break;
    res += dfs(cu + 1, tot2);
  }
  return res;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  in(n,k,m);
  auto ep=enumpr(n);
  repe(p,ep)primes.push_back({p.first,p.second*k});
  cout<<dfs(0,1)<<endl;
}
0