結果

問題 No.847 Divisors of Power
ユーザー rpy3cpp
提出日時 2019-09-23 17:49:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,007 bytes
コンパイル時間 1,419 ms
コンパイル使用メモリ 172,904 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-19 04:29:26
合計ジャッジ時間 5,160 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 3 WA * 12 TLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int COUNT = 0;

vector<pair<long long, long long>> factorize(int N){
    vector<pair<long long, long long>> factors;
    for (int p = 2; p * p < N; ++p){
        int  count = 0;
        while ((N % p) == 0){
            N /= p;
            ++count;
        }
        if (count > 0) factors.emplace_back(make_pair(p, count));
    }
    if (N > 1) factors.emplace_back(make_pair(N, 1));
    return factors;
}

void dfs(int cump, int d, const vector<pair<long long, long long>> & factors, const int M){
    if (d == factors.size()){
        ++COUNT;
        return;
    }
    for (int i = 0; i <= factors[d].second and cump <= M; ++i){
        dfs(cump, d + 1, factors, M);
        cump *= factors[d].first;
    }
}

int main(){
    int N, K, M;
    cin >> N >> K >> M;
    vector<pair<long long, long long>> factors = factorize(N);
    for (auto & pk : factors){
        pk.second *= K;
    }
    dfs(1, 0, factors, M);
    cout << COUNT << endl;
    return 0;
}
0