题目描述

Output the k-th prime number.

输入

k≤10000

输出

The k-th prime number.

样例输入

  1. 10
  2. 50

样例输出

  1. 29
  2. 229
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4. const int N=1e6+;
  5. int prime[N];
  6. bool vis[N];
  7. int cnt=;
  8. void isprime(int n)
  9. {
  10. fill(vis,vis+N,false);
  11. cnt=;
  12. for(int i=; i<n; i++)
  13. {
  14. if(!vis[i])
  15. {
  16. prime[cnt++]=i;
  17. }
  18. for(int j=i+i; j<n; j+=i)
  19. {
  20. vis[j]=true;
  21. }
  22. }
  23. }
  24. int main()
  25. {
  26. int n;
  27. isprime(N);
  28. while(scanf("%d",&n)==)
  29. {
  30. printf("%d\n",prime[n-]);
  31.  
  32. }
  33. return ;
  34. }

问题 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. 【洛谷P1886】滑动窗口

    滑动窗口 [题目描述] 有N个数字,以及一个大小为k的窗口.现在这个窗口从左边开始向右滑动,每次滑动一个单位,求出每次滑动后窗口中的最大值和最小值. 思路: k<=N<=1000000,暴 ...

  2. 对象的比较与排序(三):实现IComparable<T>和IComparer<T>泛型接口

    来源:http://www.cnblogs.com/eagle1986/archive/2011/12/06/2278531.html 1:比较和排序的概念 比较:两个实体类之间按>,=,< ...

  3. py faster rcnn的lib编译出错问题

    真是好事多磨啊,计算机系统依然是14.04,而cuda依然是8.0,唯一不同的是时间不一样,下载的各种库版本有差别,GPU的driver不一样. 但是这样就出问题了,py-faster rcnn的li ...

  4. Angularjs基础(二)

    AngularJS 表达式 AngularJS 表达式写在双大括号内:{{expression}} AngularJS 表达式把数据绑定到HTML,这与ng-bind 指令有异曲同工之妙 Angula ...

  5. Nginx从搭建到配置支持HTTPS

    原文地址:https://www.xingkongbj.com/blog/nginx/nginx.html 安装 基础包 ububtu apt-get install build-essential ...

  6. js函数只触发一次

    如何让js中的函数只被执行一次?我们有时候会有这种需求,即让一个函数只执行一次,第二次调用不会返回任何有价值的值,也不会报错.下面将通过三个小demo展示使用的方法,当做个人笔记. 1.通过闭包来实现 ...

  7. ABAP术语-Business Components

    Business Components 原文:http://www.cnblogs.com/qiangsheng/archive/2007/12/26/1015254.html Group of re ...

  8. PG进程结构和内存结构

    ​ 本文主要介绍PostgreSQL数据库(后文简称PG)进程结构和内存结构,物理结构将在后续继续整理分享. ​ 上图描述了PG进程结构.内存结构和部分物理结构的内容.图中的内容包含了两个部分: PG ...

  9. 利用python和opencv批量去掉图片黑边

    import os import cv2 import numpy as np from scipy.stats import mode import time import concurrent.f ...

  10. Eclipse中各种文件的注释与取消注释的快捷键

    Eclipse中各种文件的注释与取消注释的快捷键 Java文件: 注释和取消注释的快捷键都是:CTRL + / 或 Shift+Ctrl+C JS文件: 注释和取消注释的快捷键都是:CTRL + / ...