結果

問題 No.1666 累乗数
ユーザー tko919tko919
提出日時 2021-09-04 00:10:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 205,328 KB
実行使用メモリ 13,144 KB
最終ジャッジ日時 2023-08-22 02:43:15
合計ジャッジ時間 5,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
11,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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 #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll LIM=1000000000000000000LL;

int main(){
   vector<ll> other;
   for(ll a=2;a<=1000001;a++){
      ll add=a*a;
      rep(_,0,65){
         add*=a;
         if(add>=LIM)break;
         else{
            ll sq=sqrt(add);
            if(sq*sq!=add)other.push_back(add);
         }
         if(add>=LIM/a)break;
      }
   }
   sort(ALL(other));

   int q;
   cin>>q;
   while (q--)
   {
      int x;
      cin>>x;
      x--;
      ll lb=0,rb=LIM+5;
      while(rb-lb>1){
         ll mid=(lb+rb)>>1;
         ll cnt=upper_bound(ALL(other),mid)-other.begin();
         cnt+=ll(sqrt(mid));
         if(cnt>x)rb=mid;
         else lb=mid;
      }
      cout<<rb<<'\n';
   }
   
   return 0;
}
0