Lonlife-ACM 1010 Alarm

来源:互联网 发布:域名升级访问中sdashao 编辑:程序博客网 时间:2024/05/29 14:37
A -- Alarm

Time Limit:1s Memory Limit:128MByte

Submissions:216Solved:75

DESCRIPTION
Given a number sequence [3,7,22,45,116,...][3,7,22,45,116,...]. Please tell me the kk-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 (1k10000)k (1≤k≤10000).
OUTPUT
For each case, ouput the kk-th number of the sequence in one line.
SAMPLE INPUT
214
SAMPLE OUTPUT
345
签到题,渣渣也就只会这道签到题
找规律第k个素数的平方-k ,打印素数表即可,
#include<stdio.h>#include<string.h>#include<algorithm>#define LL long longusing namespace std;long long f[101000];void init(){   long long i,j,l=1;   for(i=2;i<110000;i++)   {for(j=2;j*j<=i;j++)if(i%j==0)break;if(j*j>i)f[l++]=i;   }}int main(){    long long t,k;scanf("%lld",&t);init();while(t--){scanf("%lld",&k);LL sum=f[k]*f[k]-k;printf("%lld\n",sum);}return 0;}


0 0