結果

問題 No.1666 累乗数
ユーザー nawawannawawan
提出日時 2021-09-03 22:39:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 953 ms / 2,000 ms
コード長 1,350 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 202,300 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 23:37:18
合計ジャッジ時間 20,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,376 KB
testcase_01 AC 882 ms
4,376 KB
testcase_02 AC 886 ms
4,376 KB
testcase_03 AC 887 ms
4,376 KB
testcase_04 AC 887 ms
4,376 KB
testcase_05 AC 950 ms
4,376 KB
testcase_06 AC 953 ms
4,376 KB
testcase_07 AC 951 ms
4,376 KB
testcase_08 AC 952 ms
4,376 KB
testcase_09 AC 908 ms
4,380 KB
testcase_10 AC 908 ms
4,376 KB
testcase_11 AC 910 ms
4,376 KB
testcase_12 AC 909 ms
4,376 KB
testcase_13 AC 949 ms
4,376 KB
testcase_14 AC 951 ms
4,380 KB
testcase_15 AC 949 ms
4,376 KB
testcase_16 AC 949 ms
4,380 KB
testcase_17 AC 927 ms
4,380 KB
testcase_18 AC 934 ms
4,376 KB
testcase_19 AC 932 ms
4,380 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