結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-22 23:28:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 824 bytes |
| コンパイル時間 | 2,482 ms |
| コンパイル使用メモリ | 203,064 KB |
| 最終ジャッジ日時 | 2025-01-07 14:39:26 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fpow(int _a,int b) {
ll ans=1;
ll a=_a;
while (b) {
if (b&1) ans*=a;
a*=a;
b/=2;
}
return ans;
}
int dfs(int n,vector<pair<int,ll>> pf,int pro,int m) {
if (n==pf.size()) return 1;
int ans=0;
for (int i=0;i<=pf[n].second;i++) {
ll pro2=pro*fpow(pf[n].first,i);
if (pro2>m) break;
ans+=dfs(n+1,pf,pro2,m);
}
return ans;
}
int main() {
int n,k,m;
cin>>n>>k>>m;
map<int,int> pf;
int t=n;
for (int i=2;i*i<=t;i++)
while (t%i==0) {
pf[i]++;
t/=i;
}
if (t>1) pf[t]++;
vector<pair<int,ll>> pf2;
for (auto p:pf)
pf2.push_back({p.first,k*p.second});
cout<<dfs(0,pf2,1,m);
return 0;
}