首页 > 试题广场 >

Prime Number

[编程题]Prime Number
  • 热度指数:17301 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
Output the k-th prime number.

输入描述:
k≤10000


输出描述:
The k-th prime number.
示例1

输入

3
7

输出

5
17
头像 牛客652687585号
发表于 2022-03-04 20:27:39
#include<iostream> #include<cstdio> #include<vector> using namespace std; const int MAXN=1e5+1e4; bool isPr 展开全文
头像 鱼儿恋上水
发表于 2020-03-31 17:21:05
埃氏筛法: #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn = 10000000; int prime[maxn]; bool 展开全文
头像 MEMESOREREMEREDODOLA
发表于 2020-04-30 11:55:05
/* 方法一:枚举(不需要重复求子问题,稍有优化) #include <cstdio> #include <iostream> #include <vector> #include <algorithm> 展开全文
头像 NiDeHaiWang
发表于 2024-02-28 14:00:47
#include <iostream> using namespace std; int main() { int arr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 展开全文
头像 Xyzz1223
发表于 2022-05-03 22:23:48
使用一个vector存储已经计算过的素数,根据vector的长度判断当前需要求的素数是否已经计算过,若以及计算过,则直接通过数组的下标取出结果。 #include<cstdio> #include<iostream> #include<cmath> #includ 展开全文
头像 nzxkc
发表于 2022-02-11 23:15:53
素数筛,随便打的表 #include<iostream> using namespace std; const int N = 100010; int primes[N]; bool st[N]; int 展开全文
头像 AuroraYxh
发表于 2023-07-21 15:11:09
#include <bits/stdc++.h> #include <vector> using namespace std; const int N=5e5+10; bool st[N]; vector<int> prime; void get_prim 展开全文
头像 Montage.
发表于 2022-01-21 12:30:59
依次向后判断即可 #include #include #include using namespace std; bool isSu(int n){ int bound = sqrt(n); for(int i=2;i<=bound;i++){ if(n%i==0){ return fa 展开全文
头像 准备笔试的哈士奇很坦荡
发表于 2023-03-20 21:04:34
#include <stdio.h> int main() { int n,a[100007]={0}; int i=0; int j,flag; while (scanf("%d",&n)!=EOF) { //scanf("%d",&n 展开全文
头像 Ooops!
发表于 2023-09-13 18:24:05
#include<bits/stdc++.h> using namespace std; vector<int> dp(110000,1); void zhi(){ for(int i=2;i<110000;i++){ if(dp[i]== 展开全文