先找出所有的数,排序,然后o(1)效率询问
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std; long long Ans[];
int tot;
map<long long, int>Cun;
const long long INF = 1e18; void init()
{
tot = ;
Cun.clear();
Cun[] = ;
Ans[tot] = ;
} int main()
{
int head = ;
init();
while ()
{
if (Ans[head] == ) break;
long long h = Ans[head];
if (h * > INF || Cun[h * ] == ) {}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
} if (h * > INF || Cun[h * ] == ){}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
} if (h * > INF || Cun[h * ] == ) {}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
} if (h * > INF || Cun[h * ] == ) {}
else
{
tot++;
Ans[tot] = h * ;
Cun[h * ] = ;
}
head++;
}
sort(Ans, Ans + tot + );
int T;
scanf("%d", &T);
while (T--)
{
int n;
scanf("%d", &n);
printf("%lld\n", Ans[n - ]);
}
return ;
}