結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
mag
|
| 提出日時 | 2020-08-15 03:12:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,122 bytes |
| コンパイル時間 | 1,818 ms |
| コンパイル使用メモリ | 177,452 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-10 17:07:12 |
| 合計ジャッジ時間 | 5,706 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 3 WA * 12 TLE * 1 -- * 10 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#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<int,int> enumpr(int n) {
map<int,int> V;
for(int i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
if(n>1) V[n]++;
return V;
}
int fastpow(int x, int n) {
int ret = 1;
while (0 < n) {
if ((n % 2) == 0) x *= x, n >>= 1;
else ret *= x, --n;
}
return ret;
}
int n,k,m;
//候補を決定
vector<pair<int, int>> primes;
int dfs(int cu, int tot) {
if(cu == primes.size()) return 1;
int res = 0;
rep2(cnt, 0, primes[cu].second + 1) {
int 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