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. IdentityServer4-前后端分离之Vue

    原文:IdentityServer4-前后端分离之Vue 前言 之前文章讲到如何使用Node.js+Express构建JavaScript客户端,实现前后端分离.本节将介绍如何使用Vue实现前后端分离 ...

  2. CentOS6.3从光盘安装gcc(更改yum源)[转]

    转自:http://www.linuxidc.com/Linux/2012-11/73826.htm 一.加载光盘镜像 加载本地bin-DVD镜像文件到虚拟机系统,如图所示: 二.更改yum源 1.挂 ...

  3. mysql死锁-查询锁表进程-分析锁表原因

    查询锁表进程: 1.查询是否锁表 show OPEN TABLES where In_use > 0;   2.查询进程     show processlist   查询到相对应的进程===然 ...

  4. 洛谷 P1702 突击考试

    P1702 突击考试 题目描述 一日,老师决定进行一次突击考试.已知每个学生都有一个考试能力等级,教室里一共有N个课桌,按照顺序排成一列,每张课桌可以坐两个人,第i张课桌坐的两个人的能力等级为(A[i ...

  5. 微信iOS SDK文档总结

    至今共19个类.分3大类. (1)请求与响应类:微信终端和第三方程序:第三方程序和微信server. BaseReq:全部请求类的基类. GetMessageFromWXReq:微信终端向第三方程序请 ...

  6. Android 主界面长按创建快捷方式

    Android中创建快捷方式主要有两种方式.一是在代码中直接加入生成桌面快捷方式的代码:二是通过小部件加入; 这篇文章主要讲另外一种方法! 1.通过在AndroidManifest文件里为Activi ...

  7. 学习bootstrap

    菜鸟教程 bootstrap开发框架 伍华聪 Bootstrap——一款超好用的前端框架

  8. 求解n位格雷码

    /************************************************************************* > File Name: Gray.cpp ...

  9. ZoomIt(投影演示辅助软件)下载、安装与运行使用

    下载ZoomIt后,打开即可使用:打开时,你讲看到如下的几个页面,这几个页面是为了介绍每个功能的使用,还可以去设定你觉得比较舒服的快捷键, 默认的是Ctrl+1屏幕放大.Ctrl+2屏幕标注,Ctrl ...

  10. Java基础学习补充 -- 异常处理和log4j日志

    Java中的异常处理 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的. Java中所有异常的基类Throwable:Throwable又分为Error类和Excepti ...