結果
問題 |
No.847 Divisors of Power
|
ユーザー |
|
提出日時 | 2019-08-22 23:38:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 823 bytes |
コンパイル時間 | 2,297 ms |
コンパイル使用メモリ | 204,108 KB |
最終ジャッジ日時 | 2025-01-07 14:39:47 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#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=fpow(pf[n].first,i)*pro; 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,ll> 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; }