結果

問題 No.847 Divisors of Power
ユーザー masayamatumasayamatu
提出日時 2019-09-29 12:31:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 169,516 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 07:13:44
合計ジャッジ時間 2,791 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int n,k,m=0 ;

long long calc(vector<pair<int, long>> &v,int i, long long val){
    if ( i == v.size()){
        return 1;
    }
        int d = v[i].first;
        long count = v[i].second;
        long long tmp = 1;
        long long ret = 0;
        for(int j = 0; j <= count; j++){
            ret += calc(v,i+1,val*tmp);
            tmp *= d;
            if(tmp * val > m){
                break;
            }
        }
        return ret;
        
}
int main(){
    cin >> n >> k >> m;
    map<int , long> d;
    for(int i = 2; i <= sqrt(n) && n > 1; i++){
        if(n % i != 0){
            continue;
        }
        while(n % i  == 0){
            ++d[i];
            n /= i;
        }
    }
    if(n != 1){
        d[n] = 1;
    }
    for(auto di : d){
        d[di.first] *= k;
    }
    vector<pair<int ,long>> v(d.begin(),d.end());
    cout << calc(v,0,1) << endl;
    
}
0