結果

問題 No.847 Divisors of Power
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-07-05 21:45:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,655 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 104,120 KB
実行使用メモリ 9,368 KB
最終ジャッジ日時 2024-04-16 07:11:34
合計ジャッジ時間 2,009 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,332 KB
testcase_01 AC 5 ms
7,520 KB
testcase_02 AC 5 ms
7,324 KB
testcase_03 AC 7 ms
7,332 KB
testcase_04 AC 6 ms
7,300 KB
testcase_05 AC 5 ms
7,500 KB
testcase_06 AC 11 ms
7,436 KB
testcase_07 AC 13 ms
7,296 KB
testcase_08 AC 12 ms
7,436 KB
testcase_09 AC 12 ms
7,484 KB
testcase_10 AC 8 ms
7,500 KB
testcase_11 AC 9 ms
7,228 KB
testcase_12 AC 9 ms
7,408 KB
testcase_13 AC 10 ms
7,272 KB
testcase_14 AC 8 ms
7,228 KB
testcase_15 AC 8 ms
8,272 KB
testcase_16 AC 12 ms
7,416 KB
testcase_17 AC 13 ms
7,236 KB
testcase_18 AC 11 ms
7,368 KB
testcase_19 AC 11 ms
7,380 KB
testcase_20 AC 13 ms
7,372 KB
testcase_21 AC 8 ms
7,632 KB
testcase_22 AC 10 ms
7,332 KB
testcase_23 AC 10 ms
7,352 KB
testcase_24 AC 10 ms
9,368 KB
testcase_25 AC 5 ms
7,292 KB
testcase_26 AC 4 ms
7,464 KB
testcase_27 AC 14 ms
7,404 KB
testcase_28 AC 5 ms
7,372 KB
testcase_29 AC 4 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int not_prime[1000001];

map<ll, ll> factorize(ll n){
    map<ll, ll> ret;
    ll i = 2;
    not_prime[2] = 0;
    fill(not_prime, not_prime+1000001, 0);
    while(n != 1 && i <= 1000000){
        if(not_prime[i]){
            ++i;
            continue;
        }
        ll j = i;
        while(j <= 1000000){
            not_prime[j] = 1;
            j += i;
        }

        while(n % i == 0){
            n /= i;
            ++ret[i];
        }

        ++i;
    }
    if(n != 1LL){
        ++ret[n];
    }
    return ret;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n,k,m;
    cin >> n >> k >> m;

    map<ll, ll> mp = factorize(n);

    vector<ll> divisors(1, 1);
    for(auto itr=mp.begin();itr!=mp.end();++itr) {
        ll f = itr->first;
        ll nf = (itr->second) * k;
        int nd = divisors.size();
        for(int i=0;i<nd;++i) {
            ll d = divisors[i];
            for(int j=1;j<=nf;++j) {
                d *= f;
                if(d > m) break;
                divisors.push_back(d);
            }
        }
    }

    cout << divisors.size() << endl;
}
0