1010 - Alarm

Time Limit:1s Memory Limit:128MByte

DESCRIPTION

Given a number sequence [3,7,22,45,116,...]

. Please tell me the k

-th number.

INPUT
A number T (T<100)

indicates the number of the input cases. Then for each case there only is one integer k (1≤k≤10000)

.
OUTPUT
For each case, ouput the k
-th number of the sequence in one line.
SAMPLE INPUT
2
1
4
SAMPLE OUTPUT
3
45
第一次做这种题,我的内心是崩溃的找规律找规律  ans=prime(n)^2-n;
来一个数列查找链接 http://oeis.org/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll a[];
ll vis[];
void getprime()
{
memset(a,,sizeof(a));
a[]=;
for(ll i=;i<;i++)
{
if(a[i]==) continue;
for(ll j=;j*i<;j++)
a[j*i]=;
}
ll ans=;
for(ll i=;i<;i++)
{
if(!a[i]) vis[ans++]=i;
if(ans>=) break;
}
}
int main()
{
ll t,n;
scanf("%lld",&t);
getprime();
while(t--)
{
scanf("%lld",&n);
printf("%lld\n", vis[n]*vis[n]-n);
}
}

玲珑学院 1010 - Alarm的更多相关文章

  1. 玲珑学院-ACM比赛1014 - Absolute Defeat

    1014 - Absolute Defeat Time Limit:2s Memory Limit:64MByte Submissions:257Solved:73 DESCRIPTION Eric ...

  2. 玲珑学院oj 1152 概率dp

    1152 - Expected value of the expression Time Limit:2s Memory Limit:128MByte Submissions:128Solved:63 ...

  3. 玲珑学院1072 【DFS】

    蛤蛤,略蠢. priority_queue 自定义优先级 和排序是反的 struct node { int x,y; friend bool operator< (node a,node b) ...

  4. 玲珑学院OJ 1023 - Magic boy Bi Luo with his excited math problem 树状数组暴力

    分析:a^b+2(a&b)=a+b  so->a^(-b)+2(a&(-b))=a-b 然后树状数组分类讨论即可 链接:http://www.ifrog.cc/acm/probl ...

  5. 玲珑学院OJ 1028 - Bob and Alice are playing numbers 字典树,dp

    http://www.ifrog.cc/acm/problem/1028 题解处:http://www.ifrog.cc/acm/solution/4 #include <cstdio> ...

  6. 玲珑学院 1050 - array

    1050 - array Time Limit:3s Memory Limit:64MByte Submissions:494Solved:155 DESCRIPTION 2 array is an ...

  7. 玲珑学院 1052 - See car

    1052 - See car Time Limit:2s Memory Limit:64MByte Submissions:594Solved:227 DESCRIPTION You are the ...

  8. 玲珑学院 1014 Absolute Defeat

    SAMPLE INPUT 3 2 2 2 1 1 5 1 4 1 2 3 4 5 4 10 3 1 2 3 4 SAMPLE OUTPUT 1 0 15 前缀和,每个元素都判断一下. #include ...

  9. 第八届郑州轻工业学院ACM(程序设计大赛)校内预选赛

    郑州轻工业学院有一个大赛,把几个有趣的题目分享一下.下面是题目连接,喜欢了就点点... 斗破苍穹 礼上往来 统计人数 神の数 炉石传说 Mathematics and Geometry 马拉松后记 斗 ...

随机推荐

  1. [terry笔记]redhat5.5_11gR2_RAC_安装

    redhat5.5_11gR2_RAC_安装,这篇主要记录RAC安装的执行步骤,最烦琐的就是前期配置,到后面图形界面runInstaller,asmca,dbca就很容易了. --hostname检查 ...

  2. Multi-Byte Character Set & Unicode Character Set

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/49592361 编程时遇到BUG:err ...

  3. groovy : poi 导出 Excel xlsx

    參考 file:///poi-3.10-FINAL/docs/spreadsheet/how-to.html#sxssf text2xlsx.groovy 代码例如以下 package xlsx; i ...

  4. SQLSever: 怎样在select中的每一行产生不同的随机数?

    select 的随机函数有点假, 或许是由于它是基于时间来的吧, 同一select中由于时间无法错开导致产生的随机数都是一样的. 怎样做到让不同的行拥有不同的随机数呢? 以下以产生某个月的随机日期来演 ...

  5. 由老同事学习SAP所想到的

    前段时间一位老同事在微信上跟我说他们公司正计划导SAP系统,但整个IT中心几乎无人使用过SAP,知道我在这行业干了多年了,所以想问我怎么开始学习.于是我约他今天出来聊聊,顺便把手里的SAP ECC E ...

  6. Eclipse中项目进行发布到Tomcat中的位置

    Eclips配置tomcat默认是发布到.metadate\plugins\目录下的,wtpwebapps.这样在实际的tomcat目录下,就找不到发布的项目.我们可以自己进行设置,在控制栏中找到se ...

  7. Android 进程常驻(0)----MarsDaemon使用说明

    版权声明:本文为博主原创文章,未经博主允许不得转载. 这是一个轻量级的库,配置几行代码,就可以实现在Android上实现进程常驻,也就是在系统强杀下,以及360获取root权限下,clean mast ...

  8. 安卓操作sqlite3,增删改查

    创建 layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...

  9. The python programing language

    Python is an example of high-level language. As you might infer from the name “high-level language”, ...

  10. Nginx下部署TP5项目

    标签(空格分隔): linux nginx配置文件: server { listen 81; #listen [::]:80; server_name _; index index.html inde ...