結果
問題 |
No.847 Divisors of Power
|
ユーザー |
|
提出日時 | 2022-10-02 18:34:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 1,033 bytes |
コンパイル時間 | 1,999 ms |
コンパイル使用メモリ | 197,500 KB |
最終ジャッジ日時 | 2025-02-07 20:35:54 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; vector<pair<long long, long long>> prime_factorize(long long N){ vector<pair<long long, long long>> res; for(long long a = 2; a * a <= N; ++a){ if(N % a != 0) continue; long long ex = 0; while(N % a == 0) ++ex, N /= a; res.push_back({a,ex}); } if(N != 1) res.push_back({N,1}); return res; } int main(){ cin.tie(0); ios::sync_with_stdio(0); // max: 2,3,5,7,11,13,17,19,23 ll N,K,M; cin >> N >> K >> M; auto pf = prime_factorize(N); int ans = 0; function<void(int,ll)> dfs = [&](int i, ll x) -> void { if(i == int(pf.size())) { if(x <= M) ans++; } else { auto [p, e] = pf[i]; int cnt = 0; do { dfs(i + 1, x); x *= p; cnt++; } while(x <= M && cnt <= e * K); } }; dfs(0, 1LL); cout << ans << endl; }