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);
}
}

最新文章

  1. iOS Swift-HelloWord
  2. Java for LeetCode 210 Course Schedule II
  3. java数组元素的输出
  4. Calendar GData API / Google Calendar Connectors deprecation
  5. WPF 中,如何使用自定义的resources
  6. Winfroms---看看吧客官~
  7. 关于java函数参数的修改能否带出来
  8. javascript 的工具方法 --- 类型判断
  9. Spring对jdbc支持
  10. [原创]KVM虚拟化管理平台的实现
  11. hdu_1015(dfs)
  12. Java语言基础组成
  13. Java作业九(2017-11-6)
  14. js原生倒计时
  15. svn解决冲突问题
  16. 和我一起打造个简单搜索之SpringDataElasticSearch关键词高亮
  17. SharePoint 2013 Workflow Manager 1.0 卸载
  18. ajax post 请求 ,java端使用 request.getParameter 获取不到数据问题
  19. Notepad++中支持Markdown
  20. Java调试那点事[转]

热门文章

  1. Adobe Flex迷你教程 —Flex4全屏显示
  2. GenIcam标准(二)
  3. 【BZOJ 1260】[CQOI2007]涂色paint
  4. System and method for assigning a message
  5. LeetCode 232: Implement Queue using Stacks
  6. find the safest road HDU杭电1596【Dijkstra || SPFA】
  7. 2014 百度之星 1003 题解 Xor Sum
  8. bzoj3931: [CQOI2015]网络吞吐量(spfa+网络流)
  9. Xshell高级后门完整分析报告
  10. VS C/C++ 调用lua库(编译出错)