結果
問題 |
No.847 Divisors of Power
|
ユーザー |
![]() |
提出日時 | 2019-07-05 23:52:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 1,711 ms |
コンパイル使用メモリ | 175,592 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-06 23:24:16 |
合計ジャッジ時間 | 2,635 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, k, m; cin >> n >> k >> m; if (n == 1) { cout << 1 << endl; return 0; } vector<pair<int64_t, int64_t>> pf; for (int64_t i = 2; i * i <= n; i++) { if (n % i == 0) { pf.push_back({i, 0}); } while (n % i == 0) { pf.rbegin()->second++; n /= i; } } if (n != 1) { pf.push_back({n, 1}); } sort(pf.begin(), pf.end()); for (auto &p : pf) { p.second *= k; } auto f = [&](auto &g, int64_t now = 1, int64_t i = 0) -> int64_t { if (i == pf.size()) { return 1; } int64_t r = 0; for (int64_t j = 0, p = 1; j <= pf[i].second; j++, p *= pf[i].first) { if (m < now * p) { break; } r += g(g, now * p, i + 1); } return r; }; cout << f(f) << endl; return 0; }