【解题方法】要么观察,要么丢到oeishttp://oeis.org/search?q=3%2C7%2C22%2C45%2C116&language=english&go=Search搜一下,都可以确定这个数列是prime(n)^2-n,还要注意爆int的trick!

【AC 代码】

//
//Created by just_sort 2016/9/26 10:30
//Copyright (c) 2016 just_sort.All Rights Reserved
//

#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1000005;
bool is[maxn];
int prime[maxn];
void getprim()
{
    memset(is,true,sizeof(is));
    is[1] = 0;
    int tp = 0;
    for(int i = 2; i < maxn; i++){
        if(is[i]){
            prime[++tp] = i;
            for(int j = 2*i; j < maxn; j+=i) is[j] = false;
        }
    }
}

int main()
{
    getprim();
    int T,n;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        printf("%lld\n",1LL*prime[n]*prime[n]-1LL*n);
    }
    return 0;
}