結果

問題 No.1666 累乗数
ユーザー ktr216ktr216
提出日時 2021-09-03 22:46:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,199 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 180,880 KB
実行使用メモリ 248,348 KB
最終ジャッジ日時 2024-05-09 05:52:53
合計ジャッジ時間 6,180 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 376 ms
63,876 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int main() {
    set<ll> st;
    rep(i, 2, 1000001) {
        //cout << i << endl;
        for (ll j = 1LL * i * i; j <= 1e18 / i; j *= i) {
            ll x = j * i, y = sqrt(x);
            if (x != y * y) st.insert(x);
        }
    }
    //cout << st.size() << endl;
    //for (ll i : st) cout << i << " ";
    vector<ll> vc(0);
    for (ll i : st) vc.push_back(i);
    sort(vc.begin(), vc.end());
    int T;
    cin >> T;
    while (T-- > 0) {
        ll K;
        cin >> K;
        priority_queue<ll> ans = {};
        for (ll i = K; i > 0 || i > K - vc.size(); i--) {
            ans.push(i * i);
            //cout << i * i << ":";
            //cout << ans.size() << endl;
        }
        //cout << ans.size() << endl;
        for (ll i : vc) {
            ans.push(i);
            ans.pop();
        }
        cout << ans.top() << endl;
        /*
        cout << ans.size() << endl;
        while (!ans.empty()) {
            cout << ans.top() << ";";
            ans.pop();
        }
        */
    }
    //rep(i, 0, 100) cout << vc[vc.size() - 1 - i] << " ";
}
0