結果

問題 No.1666 累乗数
ユーザー chocorusk
提出日時 2021-09-03 21:37:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,668 bytes
コンパイル時間 3,864 ms
コンパイル使用メモリ 185,132 KB
最終ジャッジ日時 2025-01-24 05:04:35
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
bool sq[1000010];
int main()
{
int t; cin>>t;
using lll=__int128_t;
for(int i=1; i*i<=1000000; i++) sq[i*i]=1;
vector<ll> v;
for(int j=3; j<60; j+=2){
for(int i=1; i<=1000000; i++){
if(sq[i]) continue;
lll x=1;
for(int k=0; k<j; k++){
x*=i;
if(x>1e18)break;
}
if(x>1e18)break;
v.push_back(x);
}
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
while(t--){
ll n; cin>>n;
if(n==1){
cout<<1<<endl;
continue;
}
ll l=1, r=1e18;
while(r-l>1){
ll m=(l+r)/2;
int c=lower_bound(v.begin(), v.end(), m+1)-v.begin();
ll l1=0, r1=1e9+7;
while(r1-l1>1){
ll m1=(l1+r1)/2;
if(m1*m1<=m) l1=m1;
else r1=m1;
}
l1+=c;
if(l1<=n-1) l=m;
else r=m;
}
cout<<r<<endl;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0