POJ 3307 Smart Sister

先找出所有的数,排序,然后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 ;
}
上一篇:Django中的Form表单


下一篇:NodeJS学习:爬虫小探补完计划