結果
問題 |
No.847 Divisors of Power
|
ユーザー |
|
提出日時 | 2019-07-05 21:51:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,553 bytes |
コンパイル時間 | 1,417 ms |
コンパイル使用メモリ | 118,484 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-06 21:28:59 |
合計ジャッジ時間 | 2,372 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> #include <memory> #include <regex> using namespace std; void integerFactorization(long long n, vector<pair<long long, long long> >& factor) { factor.clear(); long long a = 2; while(a * a <= n){ int b = 0; while(n % a == 0){ ++ b; n /= a; } if(b > 0) factor.push_back(make_pair(a, b)); ++ a; } if(n > 1) factor.push_back(make_pair(n, 1)); } int solve(const vector<pair<long long, long long > >& factor, int i, long long x, long long m) { if(i == factor.size()) return 0; int ans = solve(factor, i+1, x, m); for(long long j=0; j<factor[i].second; ++j){ x *= factor[i].first; if(x > m) break; ++ ans; ans += solve(factor, i+1, x, m); } return ans; } int main() { long long n, k, m; cin >> n >> k >> m; vector<pair<long long, long long > > factor; integerFactorization(n, factor); for(auto& p : factor) p.second *= k; int ans = solve(factor, 0, 1, m) + 1; cout << ans << endl; return 0; }