当前位置:网站首页>模板_欧氏筛_素数
模板_欧氏筛_素数
2022-07-16 03:19:00 【这题AC再睡.】
//
#include<bits/stdc++.h>
using namespace std;
const int N=1e8+9;
int prime[N+5];
bool judge[N+5];
void sieve()
{
memset( prime,0,sizeof( prime ) );
memset( judge,0,sizeof( judge ) );
int i,j,cnt=1;
for( i=2;i<N-5;i++ )
{
if( judge[i]==0 ) prime[cnt++]=i;
for( j=1;j<cnt && i<N/prime[j];j++ )
{
judge[i*prime[j]]=1;
if( i%prime[j]==0 ) break;
}
}
}
int main()
{
sieve();
int n,q,x;
while( cin>>n>>q )
{
while( q-- )
{
scanf( "%d",&x );
printf( "%d\n",prime[x] );
}
}
return 0;
}边栏推荐
- Hcip day 5 notes
- 论文阅读:Pyramid Scene Parsing Network
- What capabilities should an excellent smart exhibition hall have
- 示波器的带宽介绍
- Write essays on MySQL questions (keyword records)
- laravel-excel导出数据,对数据进行样式修改,数据处理
- Mgre/ospf comprehensive experiment
- 股价跌穿!慕思这是要为“智商税”买单了吗?
- 一文速学-PySpark数据分析基础:Spark本地环境部署搭建
- Theoretical basis of zoom tracking
猜你喜欢

【RT-Thread】nxp rt10xx 设备驱动框架之--uart搭建和使用

STL tips
![[golang | GRC] GRC server streaming service end stream practice](/img/c6/b7a81894be1bb60d19311abfc07800.png)
[golang | GRC] GRC server streaming service end stream practice

ES6 browser support and running environment support detection and ES6 transcoding Es5

Reduce debugging costs by 50%. Xiaojiang IOT pushes a remote serial port debugging assistant

What capabilities should an excellent smart exhibition hall have

List of ICP license application process in 2022

股价跌穿!慕思这是要为“智商税”买单了吗?

ReversingKr-wp(4)

mysql触发器和存储过程
随机推荐
What is the future of privacy computing and NFT under the wave of Web3.0
HMS core graphics and image technology shows the latest functions and application scenarios, and accelerates the construction of digital intelligence life
【RT-Thread】nxp rt10xx 设备驱动框架之--uart搭建和使用
【编程强训10】井字棋+密码强度等级
Source insight 4 what about Chinese garbled code?
股价跌穿!慕思这是要为“智商税”买单了吗?
吉时利万用表DMM6500
Runtimeerror: the size of tensor a (4) must match the size of tensor B (3) at non singleton
SSH远程端口转发
ES6 browser support and running environment support detection and ES6 transcoding Es5
金仓数据库 KingbaseES SQL 语言参考手册 (3.1.1.6. 布尔类型、3.1.1.7. 位串类型)
Network protocol -- concept and function analysis of seven layer, five layer and four layer protocols
Use of zip/enumerate/map function
金仓数据库 KingbaseES SQL 语言参考手册 (3.1.2. 域类型)
ReversingKr-wp(7)
【编程强训5】 连续最大和+统计回文
添加右键新建Markdown文件
HMS Core图形图像技术展现最新功能和应用场景,加速构建数智生活
Word -- set tab width
Reduce debugging costs by 50%. Xiaojiang IOT pushes a remote serial port debugging assistant