結果
問題 | No.1666 累乗数 |
ユーザー |
|
提出日時 | 2021-09-04 06:20:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 1,895 bytes |
コンパイル時間 | 2,424 ms |
コンパイル使用メモリ | 201,396 KB |
最終ジャッジ日時 | 2025-01-24 07:41:13 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #include <string> #include <sstream> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef long double ld; using P=pair<ll,ll>; const ld INF=1e18; const int mod=1e9+7; ll f(ll a,ll b){ ll res=1; rep(i,b){ res*=a; } return res; } void solve(){ vector<ll>s(1000001); rep(i,1001){ s[i*i]=1; } vector<ll>t; for(int i=3;i<=60;i+=2){ ll j=1; ll lim=pow(1e18+10000,1.0/i); while(j<=lim){ if(!s[j]){t.push_back(f(j,i));} j++; } } sort(t.begin(),t.end()); t.erase(unique(t.begin(),t.end()),t.end()); auto calc=[&](ll n){ ll l=0,r=1e9+5; while(r-l>1){ ll mid=(l+r)/2; if(mid*mid<=n){ l=mid; } else{ r=mid; } } ll add=upper_bound(t.begin(),t.end(),n)-t.begin(); return l+add; }; int T; cin>>T; rep(i,T){ ll k; cin>>k; ll l=0,r=1e18; while(r-l>1){ ll mid=(l+r)/2; if(calc(mid)>=k){r=mid;} else{l=mid;} } cout<<r<<endl; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }