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 (1≤k≤10000)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
- Lonlife-ACM 1010 Alarm
- Lonlife-ACM 1010 - Alarm(找规律+素数打表)
- Lonlife-ACM Round #7
- LonLife-ACM 1129
- Lonlife-ACM 1014 - Absolute Defeat [差分]
- 【玲珑杯 1010 Alarm】
- 玲珑杯 1010 - Alarm
- Alarm
- alarm
- alarm
- alarm
- Alarm
- Alarm
- Alarm
- alarm
- alarm
- alarm
- alarm
- poj 1375
- 在数据库中插入数据测试java后台接口数据传输
- 【Codeforces 703B - Mishka and trip】
- POJ:2585 Window Pains(简单拓扑排序+有难度打map表)
- linux学习第二篇:初识linux简单命令
- Lonlife-ACM 1010 Alarm
- SDUT数据结构实验之串三:KMP应用
- POJ 1724 ROADS
- Linux文件合并去除重复内容
- <hdoj2647>Reward
- Android-通过自定义ViewPager来高仿土巴兔选择装修风格效果(中间放大效果)
- 【mybatis深度历险系列】深入浅出mybatis中原始dao的开发和mapper代理开发
- 关于云服务器搭建的一些心得
- 一个HTTP请求的详细过程