結果

問題 No.847 Divisors of Power
ユーザー Y17Y17
提出日時 2019-07-05 22:06:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,275 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 160,736 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 07:25:13
合計ジャッジ時間 2,268 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

int tbl[100010] = {};
vector<int> so;
vector<int> soin;
int sonum[100010] = {};
int sip = 0;
int n, k, m;

int dfs(int i, int j, int num){
    if(i == sip){
        return 1;
    }

    if(j == sonum[i]){
        return dfs(i+1, 0, num);
    }

    if(num * soin[i] <= m){
        return dfs(i+1, 0, num) + dfs(i, j+1, num*soin[i]);
    }else{
        return dfs(i+1, 0, num);
    }
}

signed main(){

    cin >> n >> k >> m;

    for(int i = 2;i < 100010;i++){
        if(tbl[i] == 0){
            so.push_back(i);
            for(int j = i*2;j < 100010;j+=i){
                tbl[j] = 1;
            }
        }
    }

    int tmp = n;

    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

    int sp = 0;

    while(tmp > 1){
        if(tmp % so[sp] == 0){
            soin.push_back(so[sp]);
            while(tmp % so[sp] == 0){
                sonum[sip]++;
                tmp /= so[sp];
            }
            sonum[sip] *= k;
            sip++;
        }

        sp++;

        if(tmp > 1 && sp == so.size()){
            soin.push_back(tmp);
            sonum[sip] = 1;
            sip++;
            break;
        }
    }


    cout << dfs(0, 0, 1) << endl;

    return 0;
}
0