二分,然后用莫比乌斯做就行了...
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 50005;
int not_prime[maxn];
int prime[maxn];
int mu[maxn];
int K, p_cnt;
void Init()
{
mu[1] = 1;
p_cnt = 0;
for(int i = 2; i < maxn; i++) {
if(!not_prime[i]) {
prime[p_cnt++] = i;
mu[i] = -1;
}
for(int j = 0; j < p_cnt && i * prime[j] < maxn; j++) {
not_prime[i * prime[j]] = 1;
if(i % prime[j]) mu[i * prime[j]] = -mu[i];
else {
mu[i * prime[j]] = 0;
break;
}
}
}
}
bool check(LL x)
{
int tt = sqrt(x);
LL res = 0;
for(LL i = 1; i <= tt; i++) {
res += mu[i] * (x / (i * i));
}
return res >= K;
}
void work()
{
scanf("%d", &K);
LL top = 2e9, bot = 1, mid, res;
while(top >= bot) {
mid = (bot + top) >> 1;
if(check(mid)) res = mid, top = mid - 1;
else bot = mid + 1;
}
printf("%lld\n", res);
}
int main()
{
//freopen("data", "r", stdin);
Init();
int _;
scanf("%d", &_);
while(_--) work();
return 0;
}