結果

問題 No.847 Divisors of Power
ユーザー TAISA_TAISA_
提出日時 2019-07-05 22:56:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,233 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 173,600 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 07:58:01
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, m;
    cin >> n >> k >> m;
    vector<ll> v;
    set<ll> st;
    for(ll i = 1; i <= sqrt(n); i++) {
        if(n % i == 0) {
            if(i <= m) {
                v.push_back(i);
                st.insert(i);
            }
            if(n / i <= m) {
                v.push_back(n / i);
                st.insert(n / i);
            }
        }
    }
    vector<ll> v2 = v;
    for(int i = 0; i < min(k - 1LL, 31LL); i++) {
        vector<ll> v3;
        for(int j = 0; j < v.size(); j++) {
            for(int k = 0; k < v2.size(); k++) {
                if(v[j] * v2[k] > m) {
                    continue;
                }
                if(st.count(v[j] * v2[k])) {
                    continue;
                }
                v3.push_back(v[j] * v2[k]);
                st.insert(v[j] * v2[k]);
            }
        }
        for(auto& e : v3) {
            v2.push_back(e);
        }
    }
    cout << st.size() << endl;
}
0