题目描述

Output the k-th prime number.

输入

k≤10000

输出

The k-th prime number.

样例输入

10
50

样例输出

29
229
#include<bits/stdc++.h>

using namespace std;
const int N=1e6+;
int prime[N];
bool vis[N];
int cnt=;
void isprime(int n)
{
fill(vis,vis+N,false);
cnt=;
for(int i=; i<n; i++)
{
if(!vis[i])
{
prime[cnt++]=i;
}
for(int j=i+i; j<n; j+=i)
{
vis[j]=true;
}
}
}
int main()
{
int n;
isprime(N);
while(scanf("%d",&n)==)
{
printf("%d\n",prime[n-]); }
return ;
}

问题 B: Prime Number的更多相关文章

  1. FZU 1649 Prime number or not米勒拉宾大素数判定方法。

    C - Prime number or not Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  2. 每日一九度之 题目1040:Prime Number

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...

  3. LintCode-Kth Prime Number.

    Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7. The eli ...

  4. 10 001st prime number

    这真是一个耗CPU的运算,怪不得现在因式分解和素数查找现在都用于加密运算. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13 ...

  5. [LeetCode] Prime Number of Set Bits in Binary Representation 二进制表示中的非零位个数为质数

    Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime ...

  6. [Swift]LeetCode762. 二进制表示中质数个计算置位 | Prime Number of Set Bits in Binary Representation

    Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime ...

  7. 10_ for 练习 _ is Prime Number ?

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  8. 762. Prime Number of Set Bits in Binary Representation二进制中有质数个1的数量

    [抄题]: Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a ...

  9. LeetCode 762 Prime Number of Set Bits in Binary Representation 解题报告

    题目要求 Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a ...

  10. [LeetCode] 762. Prime Number of Set Bits in Binary Representation_Easy

    Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime ...

随机推荐

  1. WSASocket()与Socket()的区别 转

    /**************************************************** WSASocket是Windows专用,支持异步操作:socket是unix标准,只能同步操 ...

  2. Unity让带有Rigidbody组件的游戏对象停止运动

    Rigidbody rigidbody = transform.GetComponent<Rigidbody>(); rigidbody.velocity = Vector3.zero; ...

  3. mysql获取汉字首字母函数

    DELIMITER ;;CREATE FUNCTION `GET_FIRST_PINYIN_CHAR`(PARAM VARCHAR(255)) RETURNS VARCHAR(2) CHARSET u ...

  4. 每天一个Linux命令(6):rmdir命令

    rmdir命令用来删除空目录 注意:子目录被删除之前应该是空目录.就是说,该目录中的所有文件必须用rm命令全部,另外,当前工作目录必须在被删除目录之上,不能是被删除目录本身,也不能是被删除目录的子目录 ...

  5. Python常用模块之time和datetime

    1.时间的格式化 结构化时间 ##把字符串时间转换成结构化时间 time.strptime("2017-06-21","%Y-%m-%d") ##把结构化时间转 ...

  6. fjutacm 2492 宠物收养所 : Splay 模板 O(nlogn)

    /** problem: http://www.fjutacm.com/Problem.jsp?pid=2492 Splay blog: https://tiger0132.blog.luogu.or ...

  7. 转载:Spring使用p名称空间配置属性

    这篇博客简明扼要地介绍了Spring中p命名空间的使用,笔者在此转载一下. 原文链接:https://blog.csdn.net/liaomin416100569/article/details/49 ...

  8. vue-cli+ webpack 搭建项目todolist

    本文接着之前的todolist例子,通过vue-cli + webpack 搭建项目:针对于vue-cli 2.x版本,更高版本找官网https://cli.vuejs.org/guide/insta ...

  9. git中如何忽略文件上传?

    使用原因:至于我们为什么要使用git忽略文件,原因很多.就比如我自己的情况吧!自己一个人多地方开发,为了代码同步,这样很方便.但是有个问题就是,我创建 的是开源项目,上面有一些服务器上面的配置信息,这 ...

  10. HTTP-Http状态码301和302的区别

    官方解释: 301 redirect: 301 代表永久性转移(Permanently Moved) 302 redirect: 302 代表暂时性转移(Temporarily Moved ) 共同点 ...