結果
| 問題 | No.847 Divisors of Power |
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-12-27 01:09:01 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 962 bytes |
| 記録 | |
| コンパイル時間 | 2,971 ms |
| コンパイル使用メモリ | 286,536 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-27 01:09:06 |
| 合計ジャッジ時間 | 4,777 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
ll n, k, m;
cin >> n >> k >> m;
vector<pair<ll, ll>> pf;
for (int i = 2; i * i <= n; ++i) {
if (n % i != 0) continue;
int cnt = 0;
while (n % i == 0) ++cnt, n /= i;
pf.push_back({ i, cnt * k });
}
if (n > 1) pf.push_back({ n, k });
vector<ll> ans;
function<void(int, ll)> dfs = [&](int idx, ll cur) {
if (idx >= pf.size()) {
assert(cur <= m);
ans.push_back(cur);
return;
}
int cnt = 0;
do {
dfs(idx + 1, cur);
cur *= pf[idx].first;
cnt++;
} while (cur <= m && cnt <= pf[idx].second);
};
dfs(0, 1);
sort(ans.begin(), ans.end());
ans.erase(unique(ans.begin(), ans.end()), ans.end());
// cerr << format("{}\n", ans);
cout << ans.size() << '\n';
return 0;
}
a01sa01to