結果

問題 No.1666 累乗数
ユーザー HaaHaa
提出日時 2021-09-04 15:54:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,069 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 171,044 KB
実行使用メモリ 7,008 KB
最終ジャッジ日時 2023-08-23 04:38:44
合計ジャッジ時間 6,283 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

map<ll,ll> mp;

ll p(ll x, ll y){
    ll res=1;
    REP(i,y) res*=x;
    return res;
}

ll f(ll x){
    if(x<=1)
        return 0;
    if(mp[x]!=0)
        return mp[x];
    ll res=x-1;
    for(int i=2;i<=60;i++){
        double r=pow(x,(double)1/i);
        ll rr=r;
        if(p(rr,i)>x) rr--;
        res-=f(rr);
    }
    return mp[x]=res;
}

int main(){
    int t; cin >> t;
    while(t--){
        ll k; cin >> k;
        ll l=0, r=INF;
        while(r-l>1){
            ll m=(l+r)/2;
            if(m-f(m)<k)
                l=m;
            else
                r=m;
        }
        cout << l+1 << endl;
    }
    return 0;
}
0