結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-09 13:29:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,048 bytes |
| コンパイル時間 | 1,622 ms |
| コンパイル使用メモリ | 174,364 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 04:55:11 |
| 合計ジャッジ時間 | 2,580 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using Pll = pair<ll,ll>;
const int INF = 1e9;
const int MOD = 1000000007;
ll n,k,m;
vector<ll> diviser;
vector<Pll> prime;
vector<pair<long long,long long>> getPrimes_(ll x){
vector<pair<long long,long long>> res;
for(ll i = 2; i * i <= x;i++){
if(x%i ==0){
res.push_back(make_pair(i,0));
while(x%i ==0) x /= i,res.back().second += k;
}
}
if( x > 1) res.push_back(make_pair(x,k));
return res;
}
void dfs(int i,int d,ll now){
if(i == d) diviser.push_back(now);
else{
ll res = 1;
rep(j,prime[i].second+1){
if(res * now > m) break;
dfs(i+1,d,now*res);
res *= prime[i].first;
}
}
}
int main(){
cin >> n >> k >> m;
prime = getPrimes_(n);
dfs(0,prime.size(),1);
cout << diviser.size() << endl;
return 0;
}