結果
| 問題 | No.1666 累乗数 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-09-03 22:20:44 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 265 ms / 2,000 ms | 
| コード長 | 2,218 bytes | 
| コンパイル時間 | 1,549 ms | 
| コンパイル使用メモリ | 111,552 KB | 
| 実行使用メモリ | 23,632 KB | 
| 最終ジャッジ日時 | 2024-12-15 14:16:19 | 
| 合計ジャッジ時間 | 7,666 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 19 | 
ソースコード
#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("Ofast, unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <ctime>
#include <unordered_set>
#include <string>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <functional>
#include <queue>
#include <numeric>
#include <bitset>
#include <iterator>
using namespace std;
const int N = 303, M = 18;
mt19937 gen(time(NULL));
#define forn(i, n) for (int i = 0; i < n; i++)
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define mp make_pair
#define endl '\n'
typedef long long ll;
template<typename T = int>
inline T read() {
	T val = 0, sign = 1; char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
		if (ch == '-') sign = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar())
		val = val * 10 + ch - '0';
	return sign * val;
}
vector<ll> cand;
ll root(ll x) {
	ll l = 0, r = 1e9 + 1;
	while (l < r - 1) {
		ll m = (l + r) / 2;
		if (m * m > x)
			r = m;
		else
			l = m;
	}
	return l;
}
void solve() {
    ll k = read<ll>() - 1;
    ll le = 0, ri = 4000000000000000000ll;
    while (ri - le > 1) {
        ll mid = (le + ri) / 2;
    	ll l = 1, r = mid;
	    ll num = upper_bound(all(cand), r) - lower_bound(all(cand), l);
    	num += root(r) - root(l - 1);
	    if (num <= k) {
	        le = mid;
	    } else {
	        ri = mid;
	    }
    }
    printf("%lld\n", ri);
}
void precalc() {
	ll U = 1e18;
	vector<ll> _cand = { 1 };
	for (ll i = 2; i <= 1e6; i++)
		for (ll curr = i * i * i; curr <= U; curr *= i) {
			_cand.push_back(curr);
			if (curr > U / i) break;
		}
	sort(all(_cand));
	_cand.erase(unique(all(_cand)), _cand.end());
	for (const ll &u : _cand) {
		ll x = root(u);
		if (x * x == u) continue;
		cand.push_back(u);
	}
    debug("Precalc: %.3f\n", (double)(clock()) / CLOCKS_PER_SEC);
}
signed main() {
    precalc();
	int t = read();
    clock_t tot = clock();
	while (t--) {
		clock_t z = clock();
		solve();
		//debug("Test: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	}
    debug("Total Time: %.3f\n", (double)(clock() - tot) / CLOCKS_PER_SEC);
}
            
            
            
        