题目描述

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. Oracle数据库中游标的游标的使用

    本人不喜欢说概念啥的,就直接说明使用方法吧 案例1: DECALRE --声明游标 CURSOR C_USER(C_ID NUMBER) IS SELECT NAME FROM USER WHERE ...

  2. wubiuefi-支持新版本ubuntu的wubi

    由于某些原因,ubuntu官方不再提供新版的wubi 这就使得部分想快速且安全尝试新版ubuntu的用户望而却步 最近在外文网站找到了wubi的新版本wubiuefi,支持最新版的ubuntu 目前支 ...

  3. GNS3的安装和配置

    一.为什么安装GNS3 简单说来它是dynamips的一个图形前端,相比直接使用dynamips这样的虚拟软件要更容易上手和更具有可操作性.更重要的一点是很多Cisco实验在cisco packet ...

  4. Vue组件通讯黑科技

    Vue组件通讯 组件可谓是 Vue框架的最有特色之一, 可以将一大块拆分为小零件最后组装起来.这样的好处易于维护.扩展和复用等. 提到 Vue的组件, 相必大家对Vue组件之间的数据流并不陌生.最常规 ...

  5. 【PTA 天梯赛训练】六度空间(广搜)

    “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论.这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够 ...

  6. 构建高可靠hadoop集群之5-服务级别授权

    本人翻译自: http://hadoop.apache.org/docs/r2.8.0/hadoop-project-dist/hadoop-common/ServiceLevelAuth.html ...

  7. JAVA | 学生选课系统

    这里使用JAVA语言编写的简易的学生选课系统,展现的都是这个系统核心代码. 其中有不足欢迎批评和指正! 链接数据库的代码 package connection;//连接数据库student impor ...

  8. .scripts/mysql_install_db: 没有那个文件或目录

    .scripts/mysql_install_db: 没有那个文件或目录 查了好多地方,在书上找到了解决方案,太不容易了 原因与解决方法: 系统与MYSQL版本不同,系统64位使用64位MYSQL,3 ...

  9. 在Vue项目里面使用d3.js

    之前写一个 Demo里面 有些东西要使用d3实现一些效果 但是在很多论坛找资源都找不到可以在Vue里面使用D3.js的方法,npm 上面的D3相对来说 可以说是很不人性化了 完全没有说 在webpac ...

  10. Mina 组件介绍之 IoAcceptor 与 IoConnector

    在网络通信中,Socket通信的双方分为服务端与客户端,在Java NIO 的实现中采用Socket/ServerSocket, SocketChannel/ServerSocketChannel分别 ...