結果

問題 No.847 Divisors of Power
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-22 23:38:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 2,681 ms
コンパイル使用メモリ 208,356 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 09:01:46
合計ジャッジ時間 4,165 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 15 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0