玲珑学院 1010 - Alarm
2024-08-31 15:48:11
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);
}
}
最新文章
- iOS Swift-HelloWord
- Java for LeetCode 210 Course Schedule II
- java数组元素的输出
- Calendar GData API / Google Calendar Connectors deprecation
- WPF 中,如何使用自定义的resources
- Winfroms---看看吧客官~
- 关于java函数参数的修改能否带出来
- javascript 的工具方法 --- 类型判断
- Spring对jdbc支持
- [原创]KVM虚拟化管理平台的实现
- hdu_1015(dfs)
- Java语言基础组成
- Java作业九(2017-11-6)
- js原生倒计时
- svn解决冲突问题
- 和我一起打造个简单搜索之SpringDataElasticSearch关键词高亮
- SharePoint 2013 Workflow Manager 1.0 卸载
- ajax post 请求 ,java端使用 request.getParameter 获取不到数据问题
- Notepad++中支持Markdown
- Java调试那点事[转]
热门文章
- Adobe Flex迷你教程 —Flex4全屏显示
- GenIcam标准(二)
- 【BZOJ 1260】[CQOI2007]涂色paint
- System and method for assigning a message
- LeetCode 232: Implement Queue using Stacks
- find the safest road HDU杭电1596【Dijkstra || SPFA】
- 2014 百度之星 1003 题解 Xor Sum
- bzoj3931: [CQOI2015]网络吞吐量(spfa+网络流)
- Xshell高级后门完整分析报告
- VS C/C++ 调用lua库(编译出错)