結果

問題 No.1666 累乗数
ユーザー nawawannawawan
提出日時 2021-09-03 22:39:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 933 ms / 2,000 ms
コード長 1,350 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 204,136 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 05:36:35
合計ジャッジ時間 20,601 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
5,248 KB
testcase_01 AC 904 ms
5,248 KB
testcase_02 AC 901 ms
5,376 KB
testcase_03 AC 909 ms
5,376 KB
testcase_04 AC 910 ms
5,376 KB
testcase_05 AC 924 ms
5,376 KB
testcase_06 AC 928 ms
5,376 KB
testcase_07 AC 933 ms
5,376 KB
testcase_08 AC 932 ms
5,376 KB
testcase_09 AC 924 ms
5,376 KB
testcase_10 AC 921 ms
5,376 KB
testcase_11 AC 921 ms
5,376 KB
testcase_12 AC 923 ms
5,376 KB
testcase_13 AC 930 ms
5,376 KB
testcase_14 AC 932 ms
5,376 KB
testcase_15 AC 932 ms
5,376 KB
testcase_16 AC 929 ms
5,376 KB
testcase_17 AC 928 ms
5,376 KB
testcase_18 AC 931 ms
5,376 KB
testcase_19 AC 929 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int T;
    cin >> T;
    set<int> s;
    while(T--){
        long long K;
        cin >> K;
        long long ub = 2000000000000000000, lb = -1;
        bool f = true;
        while(ub - lb > 1){
            long long mid = (ub + lb) / 2;
            long long cnt = 1;
            vector<long long> dp(62);
            for(int i = 1; i <= 60; i++){
                long long ok = 2000000000, ng = 0;
                while(ok - ng > 1){
                    long long m = (ok + ng) / 2;
                    long long temp = m;
                    bool f = true;
                    int rest = i;
                    while(rest--){
                        if(temp <= mid / m){
                            temp *= m;
                        }
                        else{
                            f = false;
                            break;
                        }
                    }
                    if(f) ng = m;
                    else ok = m;
                }
                dp[i + 1] = ng - 1;
            }
            for(int i = 61; i >= 2; i--){
                for(int j = i * 2; j <= 61; j += i) dp[i] -= dp[j];
                cnt += dp[i];
            }
            if(cnt >= K) ub = mid;
            else lb = mid;
        }
        cout << ub << endl;
    }
}
0