結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
12,120 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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:45:13: 警告: ‘add’ may be used uninitialized [-Wmaybe-uninitialized]
   45 |          cnt+=add;
      |          ~~~^~~~~
main.cpp:43:27: 備考: ‘add’ はここで定義されています
   43 |          ll sub=sqrt(mid),add;
      |                           ^~~

ソースコード

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){
         if(add>=LIM/a)break;
         add*=a;
         {
            ll sq=sqrt(add);
            rep(off,-5,5)if(ll(sq+off)*(sq+off)==add)goto fail;
            other.push_back(add);
            fail:;
         }
      }
   }
   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();
         ll sub=sqrt(mid),add;
         rep(off,-5,5)if(ll(sub+off)*(sub+off)<=mid)add=sub+off;
         cnt+=add;
         if(cnt>x)rb=mid;
         else lb=mid;
      }
      cout<<rb<<'\n';
   }
   
   return 0;
}
0