結果
| 問題 | No.847 Divisors of Power |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-05 22:03:57 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1,384 ms / 2,000 ms |
| コード長 | 938 bytes |
| 記録 | |
| コンパイル時間 | 659 ms |
| コンパイル使用メモリ | 105,268 KB |
| 実行使用メモリ | 9,600 KB |
| 最終ジャッジ日時 | 2026-06-07 13:13:38 |
| 合計ジャッジ時間 | 4,591 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#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;
}