結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2019-10-22 14:48:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 804 bytes |
| コンパイル時間 | 1,588 ms |
| コンパイル使用メモリ | 176,524 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 01:27:38 |
| 合計ジャッジ時間 | 2,673 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
map< ll, int > prime_factor(ll n) {
map< ll, int > res;
for(ll i = 2; i * i <= n; i++) {
while(n % i == 0) {
res[i]++;
n /= i;
}
}
if(n != 1) res[n] = 1;
return res;
}
vector<pair<ll,ll>> ps;
ll n, m, k;
int dfs(int index, ll mul) {
if (index == ps.size()) return 1;
int cnt = 0;
ll t = 1;
rep(i,ps[index].second + 1) {
cnt += dfs(index+1,mul*t);
t *= ps[index].first;
if (t * mul > m) break;
}
return cnt;
}
int main(){
cin >> n >> k >> m;
auto fact = prime_factor(n);
for (auto &p : fact) ps.push_back({p.first, p.second * k});
cout << dfs(0,1) << endl;
return 0;
}
iqueue02