• 玲珑学院 1010


    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 (1k10000)

    .
    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
    ", vis[n]*vis[n]-n);
        }
    }
  • 相关阅读:
    mongoDB看这篇就够了
    放不下
    jmeter连接不上MySQL数据库的原因以及解决方法
    SecureCRT自动断开连接的解决方法
    Linux及Windows查看占用端口的进程
    网络基础知识
    selenium中driver.close()和driver.quit()的不同点
    day2_窗口句柄切换
    day6_异常捕捉
    day6_logging模块
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7182233.html
Copyright © 2020-2023  润新知