結果

問題 No.847 Divisors of Power
ユーザー magmag
提出日時 2020-08-15 03:12:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 174,084 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-04-18 23:33:58
合計ジャッジ時間 5,432 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
#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<int,int> enumpr(int n) {
  map<int,int> V;
  for(int i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
  if(n>1) V[n]++;
  return V;
}
int fastpow(int x, int n) {
  int ret = 1;
  while (0 < n) {
    if ((n % 2) == 0) x *= x, n >>= 1;
    else ret *= x, --n;
  }
  return ret;
}
int n,k,m;
//候補を決定
vector<pair<int, int>> primes;
int dfs(int cu, int tot) {
  if(cu == primes.size()) return 1;
  int res = 0;
  rep2(cnt, 0, primes[cu].second + 1) {
    int 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