結果
問題 | No.847 Divisors of Power |
ユーザー |
![]() |
提出日時 | 2019-07-05 21:54:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 601 ms / 2,000 ms |
コード長 | 1,233 bytes |
コンパイル時間 | 2,678 ms |
コンパイル使用メモリ | 213,520 KB |
最終ジャッジ日時 | 2025-01-07 05:56:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair<int, int> P; const int mod = 1000000007; const int INF = 1e18; map<int, int> res; void prime_factor(int n){ for(int i = 2; i * i <= n; i++){ while(n % i == 0){ ++res[i]; n /= i; } } if(n != 1) res[n]++; } struct S{ int val; map<int, int> mp; bool operator>(const S &s) const{ return val > s.val; } }; signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, k, m; cin >> n >> k >> m; prime_factor(n); for(auto &i : res){ i.second *= k; } S s; s.val = 1; priority_queue<S, vector<S>, greater<S> > q; q.push(s); set<int> st; st.insert(1); while(q.size()){ S now = q.top(); q.pop(); for(auto i : res){ S nxt = now; nxt.val *= i.first; if(nxt.val > m) continue; if(st.count(nxt.val)) continue; if(nxt.mp[i.first] + 1 > i.second) continue; st.insert(nxt.val); nxt.mp[i.first]++; q.push(nxt); } } cout << st.size() << endl; }