結果

問題 No.1666 累乗数
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-08-29 01:59:37
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,078 ms / 2,000 ms
コード長 1,283 bytes
コンパイル時間 7,200 ms
コンパイル使用メモリ 306,400 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-29 02:00:08
合計ジャッジ時間 30,291 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
4,376 KB
testcase_01 AC 1,047 ms
4,380 KB
testcase_02 AC 1,022 ms
4,380 KB
testcase_03 AC 996 ms
4,380 KB
testcase_04 AC 1,034 ms
4,380 KB
testcase_05 AC 1,036 ms
4,376 KB
testcase_06 AC 1,052 ms
4,380 KB
testcase_07 AC 1,048 ms
4,376 KB
testcase_08 AC 1,029 ms
4,384 KB
testcase_09 AC 1,011 ms
4,380 KB
testcase_10 AC 1,037 ms
4,380 KB
testcase_11 AC 1,057 ms
4,376 KB
testcase_12 AC 1,045 ms
4,376 KB
testcase_13 AC 1,066 ms
4,376 KB
testcase_14 AC 1,069 ms
4,380 KB
testcase_15 AC 1,071 ms
4,384 KB
testcase_16 AC 1,047 ms
4,380 KB
testcase_17 AC 1,064 ms
4,376 KB
testcase_18 AC 1,076 ms
4,380 KB
testcase_19 AC 1,078 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int h=100;
ll mpow(ll a,ll t){
  if(t==0)return 1;
  ll res=mpow(a,t/2);
  if(res==-1)return -1;
  if(res>1e9)return -1;
  res*=res;
  if(t&1){
    if(res>1e18/a)return -1;
    res*=a;
  }
  return res;
}
void sol(){
  vc<int>mv(h,-1),p(h,1);
  for(int i=2;i<h;i++)if(p[i]){
    for(int j=i*i;j<h;j+=i*i)mv[j]=0;
    for(int j=i;j<h;j+=i)mv[j]*=-1,p[j]=0;
  }
  //rep(i,h)cout<<i<<' '<<mv[i]<<"\n";
  ll k;cin>>k;
  ll wa=0,ac=1e18;
  while(ac-wa>1){
    ll x=(ac+wa)/2;
    ll kk=1;
    for(ll i=60;i>=2;i--){
      ll l=1,r=1e9+1;
      while(r-l>1){
        ll m=(r+l)/2;
        ll res=mpow(m,i);
        if(res==-1||res>x)r=m;
        else l=m;
      }
      kk+=(l-1)*mv[i];
    }
    if(kk>=k)ac=x;
    else wa=x;
  }
  
  //for(int i=2;i<=24;i++)if(24%i==0)a+=mv[i];
  //cout<<a<<"\n";
  cout<<ac<<"\n";
  return;
}
int main(){
  int t;cin>>t;
  rep(z,t)sol();
}
0