A -- Alarm
2016-08-05 21:20
113 查看
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 (1≤k≤10000)k (1≤k≤10000).OUTPUT
For each case, ouput the kk-th number of the sequence in one line.SAMPLE INPUT
2 1 4SAMPLE OUTPUT
3 45
#include<stdio.h>#include<string.h>int su[1000000]={1,1}; int i,j,l=0; int num[10001];void h(){memset(su,0,sizeof(su));for(i=2;i<=1000000;i++){if(su[i]==1)continue;for( j=i*2;j<=1000000;j+=i)su[j]=1; }}void hh(){memset(num,0,sizeof(num));for(i=1;i<10001;i++){for(j=2;j<1000000;j++){if(!su[j]){su[j]=1;num[i]=j;break;}}}}int main(){int t,k;long long sum;h();hh();scanf("%d",&t);while(t--){scanf("%d",&k);sum=(long long)num[k]*num[k]-k; printf("%lld\n",sum);}return 0;}
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 (1≤k≤10000)k (1≤k≤10000).OUTPUT
For each case, ouput the kk-th number of the sequence in one line.SAMPLE INPUT
2 1 4SAMPLE OUTPUT
3 45
相关文章推荐
- Puppet安装部署
- Squares--二分查找
- 2014 Xian Online
- 粗浅测试流程
- 素数的简单应用
- hdu 5763 Another Menning(KMP && DP)
- IT-linux-nginx
- 文章标题
- Educational Codeforces Round 4 D 扫描线思想
- hdoj 4857 逃生 (拓扑排序--逆序构图+邻接表+优先队列)
- HDU 5726 GCD
- premiere安装失败解决办法
- adb not responding,if you like to retry
- UNIX Socket(IPC)
- STL文件在医学软件开发中的应用
- 数据结构实验之串三:KMP应用
- CodeForces 231C To Add or Not to Add
- Course Schedule
- hdu5795A Simple Nim(SG函数、打表找规律)
- UVALIVE 3637 The Bookcase <dp + 动态规划>