问题 B: Prime Number
题目描述
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的更多相关文章
- FZU 1649 Prime number or not米勒拉宾大素数判定方法。
C - Prime number or not Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
- 每日一九度之 题目1040:Prime Number
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...
- 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 ...
- 10 001st prime number
这真是一个耗CPU的运算,怪不得现在因式分解和素数查找现在都用于加密运算. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13 ...
- [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 ...
- [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 ...
- 10_ for 练习 _ is Prime Number ?
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 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 ...
- 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 ...
- [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 ...
随机推荐
- Android学习笔记_47_SIM卡介绍
一.判断SIM卡属于哪个移动运营商 1.第一种方法:获取手机的IMSI码,并判断是中国移动\中国联通\中国电信 TelephonyManager telManager = (TelephonyMana ...
- 【题解】洛谷P2926 [USACO08DEC]拍头Patting Heads
洛谷P2926:https://www.luogu.org/problemnew/show/P2926 思路 对于每一个出现的数 从1到Max 凡是这个数的倍数 那么ans就加上他的个数 PS:最后要 ...
- ssd的BUG
苦恼了我一周,当然最近我有事老请假,也有原因.就是查不到我训练的SSD模型问题出在哪里,loss也在下降,但是跳动比较大.测试时,有些类效果还可以,但是有些类压根检测不出来.而根据我的经验,那些类大概 ...
- 分布式id生成
2016年08月09日 14:15:21 yuanyuanispeak 阅读数:318 编辑 一.需求缘起 几乎所有的业务系统,都有生成一个记录标识的需求,例如: (1)消息标识:message-id ...
- 使用Python对Csv文件操作
csv是Comma-Separated Values的缩写,是用文本文件形式储存的表格数据,比如如下的表格: 就可以存储为csv文件,文件内容是: No.,Name,Age,Score 1,mayi, ...
- linux系统基础之---RPM管理(基于centos7.4)
- MB/s与Mbit/s的区别
数据传输率的单位一般采用MB/s或Mbit/s,尤其在内部数据传输率上官方数据中更多的采用Mbit/s为单位.此处有必要讲解一下两个单位二者之间的差异: MB/s的含义是兆字节每秒,Mbit/s的含义 ...
- H5混合开发进阶
混合开发: 原生app里面,IOS 安卓的原生app里面,嵌套h5界面. 通过原生app里的一个webView盒子进行交互.webView是原生app内置的一个XXX,里面可以放置h5界面.可以相互调 ...
- ctf题目writeup(6)
2019.2.2 依旧是bugku上面的题目,地址:https://ctf.bugku.com/challenges 1. 解压后是60多个out.zip,都是真加密,里面都是1kb的data.txt ...
- C语言实例解析精粹学习笔记——33(扑克牌的结构表示)
实例33: 使用“结构”定义一副扑克牌,并对变量赋值,输出结果 思路: 扑克牌有4种花色,用枚举类型表示花色,其他都是结构体的简单应用 程序代码: #include <stdio.h> # ...