結果

問題 No.847 Divisors of Power
ユーザー m-44m-44
提出日時 2019-09-08 17:30:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 175,324 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:34:28
合計ジャッジ時間 2,797 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, k, m;
long long calc(vector<pair<int, long> > &v, int i, long long val) {
  if (i == v.size()) {
    return 1;
  }
  int d = v[i].first;
  long cnt = v[i].second;
  long long tmp = 1;
  long long ret = 0;
  for (int j=0; j<=cnt; j++) {
    ret += calc(v, i+1, val*tmp);
    tmp *= d;
    if (tmp * val > m) {
      break;
    }
  }
  return ret;
}
int main() {
  cin>>n>>k>>m;
  map<int, long> d;
  for (int i=2; i<=sqrt(n) && n > 1; i++) {
    if (n % i != 0) {
      continue;
    }
    while (n % i == 0) {
      ++d[i];
      n /= i;
    }
  }
  if (n != 1) {
    d[n] = 1;
  }
  for (auto di: d) {
    d[di.first] *= k;
  }
  vector<pair<int, long> > v(d.begin(), d.end());
  cout<<calc(v, 0, 1)<<endl;
}
0