結果
| 問題 |
No.1666 累乗数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-04 08:53:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,177 bytes |
| コンパイル時間 | 1,611 ms |
| コンパイル使用メモリ | 172,052 KB |
| 実行使用メモリ | 64,968 KB |
| 最終ジャッジ日時 | 2024-12-17 14:37:39 |
| 合計ジャッジ時間 | 62,872 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "debug.hpp"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
ll K;
set<ll> st;
void calc_init() {
for (ll i = 3; i < 62; i++) {
for (ll j = 2; j <= 1e6; j++) {
double t = pow(j, i);
if (t > 1e18) break;
ll x = pow(j, i);
ll sq = sqrt(x);
if ((sq + 1) * (sq + 1) <= x) sq++;
if (sq * sq > x) sq--;
if (sq * sq != x) {
st.insert(x);
if (x < 100) debug(x);
}
}
}
}
bool isOK(ll key) {
ll max = sqrt(key);
if ((max + 1) * (max + 1) <= key) max++;
if (max * max > key) max--;
ll l = distance(st.begin(), st.upper_bound(key));
ll cnt = max + l;
return (cnt >= K);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
calc_init();
ll T; cin >> T;
for (ll t = 0; t < T; t++) {
cin >> K;
// N以下の累乗数はK個以下?
ll ok = 2e18, ng = 0;
while (abs(ok - ng) > 1) {
ll mid = (ok + ng) / 2;
if (isOK(mid)) ok = mid;
else ng = mid;
}
cout << ok << '\n';
}
return 0;
}