結果
| 問題 | 
                            No.847 Divisors of Power
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-08-22 23:28:56 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 824 bytes | 
| コンパイル時間 | 2,150 ms | 
| コンパイル使用メモリ | 202,968 KB | 
| 最終ジャッジ日時 | 2025-01-07 14:39:37 | 
| 
                            ジャッジサーバー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=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,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;
}