玲珑学院 1010 - Alarm

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[105000];
ll vis[10006];
void getprime()
{
    memset(a,0,sizeof(a));
    a[1]=1;
    for(ll i=2;i<105000;i++)
    {
        if(a[i]==1) continue;
        for(ll j=2;j*i<105000;j++)
            a[j*i]=1;
    }
    ll ans=1;
    for(ll i=2;i<105000;i++)
    {
        if(!a[i]) vis[ans++]=i;
        if(ans>=10002) break;
    }
}
int main()
{
    ll t,n;
    scanf("%lld",&t);
    getprime();
    while(t--)
    {
        scanf("%lld",&n);
        printf("%lld\n", vis[n]*vis[n]-n);
    }
}
时间: 2024-11-06 04:13:38

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

玲珑学院 1128 咸鱼拷问

1128 - 咸鱼拷问 Time Limit:3s Memory Limit:128MByte Submissions:367Solved:112 DESCRIPTION 给你两个序列A,B.每个序列有N个元素,我们定义第i个位置的咸鱼值为min(A[i],A[i-1]-A[i-B[i]+1])*max(A[i],A[i-1]-.A[i-B[i]+1]).. 现在咸鱼王想知道所有的咸鱼值,于是抓住了你,让你回答这道题.你能回答他吗? INPUT 第一行包括一个整数N(1<=N<=1e5) 第二

玲珑学院 1127 咸鱼文章

1127 - 咸鱼文章 Time Limit:1s Memory Limit:128MByte Submissions:474Solved:196 DESCRIPTION elttiL moT nwod eht teerts sllac ruo god " ehT peek god " . piZ si a peehs god . tuB nehw moT seirt ot yas " peeS " , ti semoc tuo " peek "

玲珑学院 1138 - 震惊,99%+的中国人都会算错的问题

1138 - 震惊,99%+的中国人都会算错的问题 Time Limit:4s Memory Limit:128MByte Submissions:310Solved:87 DESCRIPTION 众所周知zhu是一个大厨,zhu一直有自己独特的咸鱼制作技巧.tang是一个咸鱼供应商,他告诉zhu在他那里面有N 条咸鱼(标号从1到N)可以被用来制作.每条咸鱼都有一个咸鱼值Ki,初始时Ki都是0:zhu是一个特别的人,他又M个咸数(咸鱼数字),对于每个咸数x,他都会满足所有标号是x倍数的咸鱼的咸鱼

玲珑学院 1149 - Buildings

题意:给出N,k,长度为N的数列,问有多少个区间满足区间最大值-区间最小值<=k 思路:RMQ+二分 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=2e5+10; 5 int a[N],b[N]; 6 int dp1[N][20],dp2[N][20]; 7 int n,k; 8 9 void init(){ 10 memset(dp2,127,sizeof(d

玲珑学院 1052 - See car

1052 - See car Time Limit:2s Memory Limit:64MByte Submissions:594Solved:227 DESCRIPTION You are the god of cars, standing at (a, b) point.There are some cars at point (xi,yi), . If lots of cars and you are in one line, you can only see the car that i

玲珑学院 1050 - array

1050 - array Time Limit:3s Memory Limit:64MByte Submissions:494Solved:155 DESCRIPTION 2 array is an array, which looks like: 1,2,4,8,16,32,64......a1=1 ,a[i+1]/a[i]=2; Give you a number array, and your mission is to get the number of subsequences ,wh

玲珑学院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> #include <cstring> #include <queue> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; const int N =

玲珑学院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/problem/1023 吐槽:这个题本来是mod(2^40),明显要用快速乘啊,但是用了以后狂T,不用反而过了,不懂出题人 #include <iostream> #include <algorithm> #include <cmath> #include <vector&g

V3学院带你学习-缩短汉明码Hamming(12,8)的FPGA实现

此文章为原创出自 V3学院 www.v3edu.org,FPGA培训专家汉明码是一种实现简单并且可以检测和纠正错误的编码, 汉明码是在原编码的基础上附加一部分数据比特,使其满足纠错码的条件.它属于线性分组码,由于线性码的编码和译码容易实现,至今仍是应用最广泛的一类码.V3学院FPGA Verilog 汉明码实现,Hamming(12,8)表示数据位长K=8,编码后码字长N=12,校验位长R=12-8=4,最小汉明距离是H=3(观察其生成矩阵,不同行向量间最少不同比特的数量),纠错能力为(H-1)