Alarm
DESCRIPTION
Given a number sequence
[
3
,
7
,
22
,
45
,
116
,
.
.
.
]
[3,7,22,45,116,…]. Please tell me the
k
k-th number.
INPUT
A number
T
(
T
<
100
)
T (T<100) indicates the number of the input cases. Then for each case there only is one integer
k
(
1
≤
k
≤
10000
)
k (1≤k≤10000).
OUTPUT
For each case, ouput the
k
k-th number of the sequence in one line.
SAMPLE INPUT
2
1
4
SAMPLE OUTPUT
3
45
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#define K 1000011
#define INF 0x3f3f3f
using namespace std;
long long a[K]={1,1};
long long st[K];
long long ans;
int main()
{
int l,i,j,N,t=1;
for(i=2;i<1000;i++)
{
if(!a[i])
{
for(j=i*i;j<K;j+=i)
a[j]=1;
}
}
for(i=2;i<1100000;i++)
{
if(!a[i])
st[t++]=i;
}
scanf("%d",&N);
while(N--)
{
scanf("%d",&l);
ans=st[l]*st[l]-l;
printf("%lld\n",ans);
}
return 0;
}