結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
mag
|
| 提出日時 | 2020-08-15 03:14:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,125 bytes |
| コンパイル時間 | 1,593 ms |
| コンパイル使用メモリ | 178,372 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 17:07:37 |
| 合計ジャッジ時間 | 2,481 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repe(i,a)for(auto &i:a)
void in(){} template<typename Head,typename... Tail> void in(Head&& head,Tail&&... tail){cin>>head;in(forward<Tail>(tail)...);}
//N^Kの正の約数
//n^k=n*n...*n(k);
map<ll,ll> enumpr(ll n) {
map<ll,ll> V;
for(ll i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
if(n>1) V[n]++;
return V;
}
ll fastpow(ll x, ll n) {
ll ret = 1;
while (0 < n) {
if ((n % 2) == 0) x *= x, n >>= 1;
else ret *= x, --n;
}
return ret;
}
ll n,k,m;
//候補を決定
vector<pair<ll, ll>> primes;
int dfs(ll cu, ll tot) {
if(cu == primes.size()) return 1;
ll res = 0;
rep2(cnt, 0, primes[cu].second + 1) {
ll tot2 = tot * fastpow(primes[cu].first, cnt);
//M 以下のものの個数
if(m < tot2) break;
res += dfs(cu + 1, tot2);
}
return res;
}
int main(){
cin.tie(nullptr);ios_base::sync_with_stdio(false);
in(n,k,m);
auto ep=enumpr(n);
repe(p,ep)primes.push_back({p.first,p.second*k});
cout<<dfs(0,1)<<endl;
}
mag