結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-05 21:44:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 910 bytes |
| コンパイル時間 | 1,578 ms |
| コンパイル使用メモリ | 178,192 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 21:21:36 |
| 合計ジャッジ時間 | 2,415 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
using namespace std;
using ll = long long;
map<long long, int> factors(long long n) {
map<long long, int> res;
for (long long i = 2; i * i <= n; i++) {
while (n % i == 0) {
res[i]++;
n /= i;
}
}
if (n != 1) res[n]++;
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N, K, M;
cin >> N >> K >> M;
auto fs = factors(N);
vector<pair<ll, ll>> cnt;
for (auto f : fs) {
cnt.emplace_back(f.first, f.second * K);
}
int ans = 0;
auto dfs = [&](auto dfs, int k, ll p) {
if (k == cnt.size()) {
ans++;
return;
}
for (int i = 0; i <= cnt[k].second; i++) {
dfs(dfs, k + 1, p);
p /= cnt[k].first;
if (p == 0) break;
}
};
dfs(dfs, 0, M);
cout << ans << endl;
}