結果

問題 No.847 Divisors of Power
ユーザー takumi152takumi152
提出日時 2019-07-05 22:03:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 938 bytes
コンパイル時間 1,091 ms
コンパイル使用メモリ 89,308 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2023-07-28 23:26:11
合計ジャッジ時間 6,221 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <set>
#include <stack>
#include <algorithm>
#include <utility>

using namespace std;

typedef long long int ll;
typedef pair<ll, int> Pli;

set<ll> getDivisorSet(ll n) {
  set<ll> divisor;
  ll k = 1;
  while (k * k <= n) {
    if (n % k == 0) {
      divisor.insert(k);
      divisor.insert(n / k);
    }
    k++;
  }
  return divisor;
}

int main(){
  ll N, K, M;
  cin >> N >> K >> M;

  set<ll> divisor = getDivisorSet(N);
  set<ll> powerDivisor;
  stack<Pli> st;
  for (ll x : divisor) st.push(Pli(x, K));
  while (!st.empty()) {
    Pli now = st.top();
    st.pop();
    if (now.second <= 0) continue;
    if (now.first > M) continue;
    auto it = powerDivisor.find(now.first);
    if (it != powerDivisor.end()) continue;
    powerDivisor.insert(now.first);
    for (ll x : divisor) st.push(Pli(now.first * x, now.second - 1));
  }
  int ans = powerDivisor.size();
  cout << ans << endl;
  return 0;
}
0