Prime Number

TimeLimit: 1 Second MemoryLimit: 32 Megabyte

Totalsubmit: 399 Accepted: 88

Description

We know that the number of prime numbers is countless. Now we want to know the kth small prime number.

Input

Input contains multiple test cases. Each test case contains an integer k.(1<=k<=10^5)

Output

Print the kth small prime number.

Sample Input

1
2
4

Sample Output

2
3
7

 
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#define maxn 10000000
using namespace std;
];
];
int num;
void fun()
{
    int limt=sqrt(maxn+0.0);
    int i,j;
    num=;
    pre[num++]=;
    memset(p,,sizeof(p));
    ;i<=maxn;i+=)p[i]=;
    ;i<=limt;i+=)
    {
        if(p[i])continue;
        pre[num++]=i;
        ;
    }
    for(;i<=maxn;i++)if(!p[i])pre[num++]=i;
}
int main()
{
    //freopen("in.txt","r",stdin);
    fun();
    int n;
    while(cin >> n)
    {
        cout << pre[n-] << endl;
    }
    ;
}

【第k小素数 】 打表问题的更多相关文章

  1. BZOJ 3181([Coci2012]BROJ-最小质因子为p的第k小素数)

    3181: [Coci2012]BROJ Time Limit: 10 Sec   Memory Limit: 64 MB Submit: 26   Solved: 7 [ Submit][ Stat ...

  2. [LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  3. [Swift]LeetCode668. 乘法表中第k小的数 | Kth Smallest Number in Multiplication Table

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  4. Leetcode 668.乘法表中第k小的数

    乘法表中第k小的数 几乎每一个人都用 乘法表.但是你能在乘法表中快速找到第k小的数字吗? 给定高度m .宽度n 的一张 m * n的乘法表,以及正整数k,你需要返回表中第k 小的数字. 例 1: 输入 ...

  5. LeetCode:乘法表中的第K小的数【668】

    LeetCode:乘法表中的第K小的数[668] 题目描述 几乎每一个人都用 乘法表.但是你能在乘法表中快速找到第k小的数字吗? 给定高度m .宽度n 的一张 m * n的乘法表,以及正整数k,你需要 ...

  6. Java实现 LeetCode 668 乘法表中第k小的数(二分)

    668. 乘法表中第k小的数 几乎每一个人都用 乘法表.但是你能在乘法表中快速找到第k小的数字吗? 给定高度m .宽度n 的一张 m * n的乘法表,以及正整数k,你需要返回表中第k 小的数字. 例 ...

  7. LeetCode 378. 有序矩阵中第K小的元素(Kth Smallest Element in a Sorted Matrix) 13

    378. 有序矩阵中第K小的元素 378. Kth Smallest Element in a Sorted Matrix 题目描述 给定一个 n x n 矩阵,其中每行和每列元素均按升序排序,找到矩 ...

  8. hdu 5104 素数打表水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5104 找元组数量,满足p1<=p2<=p3且p1+p2+p3=n且都是素数 不用素数打表都能过,数据 ...

  9. SPOJ-COT-Count on a tree(树上路径第K小,可持久化线段树)

    题意: 求树上A,B两点路径上第K小的数 分析: 同样是可持久化线段树,只是这一次我们用它来维护树上的信息. 我们之前已经知道,可持久化线段树实际上是维护的一个前缀和,而前缀和不一定要出现在一个线性表 ...

随机推荐

  1. Ubuntu+Django+mod_wsgi+Apache配置过程

    Ubuntu15.10 Apache2.4( sudo apt-get install apache2 ) Python3.4( sudo apt-get install apache2 ),  [系 ...

  2. zookeeper入门知识

    ZooKeeper 是什么? ZooKeeper 顾名思义 动物园管理员,他是拿来管大象(Hadoop) . 蜜蜂(Hive) .小猪(Pig)  的管理员, Apache Hbase和 Apache ...

  3. c语言_头文件

    传统 C++ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include <assert.h> //设定插入点 #include <ctyp ...

  4. JS获取网页中HTML元素的几种方法分析

    getElementById getElementsByName getElementsByTagName 大概介绍 getElementById ,getElementsByName ,getEle ...

  5. 辨别 ShopEX Ecshop

    御剑可以识别ShopEX 或者 Ecshop 特征 ShopEX : 蓝色的icon js里有很多Cookie. <link rel="stylesheet" href=&q ...

  6. bash color

    紫色:300A24 黄色:C4A000 Tango 紫色: 200213

  7. office2003

    key:

  8. mac 命令行读取 u盘

    mac 系统命令行读取u盘

  9. mysql grant授权

    MySQL 赋予用户权限命令的简单格式可概括为: grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant sele ...

  10. ignite服务中的bean注入为空

    在写ignite服务的时候,通常服务配置在启动文件中: <bean class="org.apache.ignite.services.ServiceConfiguration&quo ...