`

Ural 1086. Cryptography

阅读更多
Cryptography


题目大意:输入一个数n(n<=15000),要求输出第n 个素数。

题目分析:简单题,考察素数筛选法。
代码:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int maxn=200010;
int prime[maxn];
int pnum;
void getPrime()
{
    pnum=0;
    prime[pnum++]=2;
    for(int i=3;i<=maxn;i+=2)
    {
        bool isprime=true;
        int cap=sqrt((double)i)+1;
        for(int j=0;j<pnum;j++)
        {
            if(prime[j]>=cap)   break;
            if(i%prime[j]==0)   {isprime=false;break;}
        }
        if(isprime) prime[pnum++]=i;
    }
}
int main()
{
    getPrime();
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        printf("%d\n",prime[n-1]);
    }
    return 0;
}

分享到:
评论

相关推荐

    Python库 | ural-0.28.0.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:ural-0.28.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Ural URAL 解题思路

    Ural解题思路 Ural解题思路 Ural解题思路 Ural解题思路

    acm_ural_1148

    Pascal acm_timus_ural_1148.pas

    Ural

    Ural

    acm_ural_1099

    Pascal acm_timus_ural_1099.pas

    URAL3D

    URAL3D

    URAL部分测试数据

    URAL(Timus Online Judge)部分测试数据 不全

    Ural 1238 源代码

    Ural 1238 源代码 涉及算法(动态规划、贪心、DFS)

    ural vol I 题解 by yuhch123 pdf

    ural 题解 yuhch123。 关于yuhch123: ioi2008 金牌第一名,这是当初它做ural 第一卷时的题解

    ural题解

    包含了ural题库中Vol_I 到Vol_III的所有题目的解题思路

    ural部分题解

    部分题解 大牛出品 Vol1-3 不是很全,约有200题左右

    URAL-PHA

    URAL-PHA

    Ural ACM 1000源代码(c++)

    Ural ACM 1000源代码(c++),vc++6.0在XPsp2下编译通过,Timus Online Judge再线测评通过

    PART II THE URAL-ALTAIC HYPOTHESIS CHAPTER IV. THE URAL-ALTAIC HYPOTHESIS AND TUNGUS MATERIAL (1931年)

    28. The Theoretical Background of the Ural-Altale Hypothesis The hypothesis of common origin of the Altaic languages,and even the Ural-Altaic languages,dates from the first half of the last century....

    hdu pku ural 题目分类

    因为大三了 不弄ACM了 所以这些就删了 删之前希望可以帮到别人

    oss-js.zip_Hold_qt oss

    This site is created and administrated by the students and graduates of the Ural Federal University. If you want to publish your problems in the archive or hold your own online programming contest, ...

    线段树题目

    大量线段树题目 zoj 1610 线段覆盖 poj 2777 线段覆盖 poj 2528 需要离散化,建树不同,需要处理不同-&gt;...ural 1019 覆盖加统计最长同一个颜色 zoj 2301 和上一题差不多,但是这个染色染的是点,注意染色为空的状况

    Ural-开源

    基于张量类模板的线性代数C ++库,可用于表示等级0的张量,标量向量,1的向量,2的矩阵,3的等级3的张量等。它还包括BLAS和LAPACK子例程的接口。

    光学镜头结构

    chieves t he integration of optical and st ruct ural design sof tware. Mainly based on black box compo2 nent met hod , t he development of optical and st ruct ural design sof tware is completed using ...

    Python库 | ural-0.25.0-py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:ural-0.25.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

Global site tag (gtag.js) - Google Analytics