标签:ret its names char stream class int logs size
蒟蒻要开始打数论模板了orz
线性筛都忘了怎么打,我太弱啦!
#pragma GCC optimize("O2")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<limits.h>
#include<ctime>
#define N 100001
typedef long long ll;
const int inf=0x3fffffff;
const int maxn=2017;
using namespace std;
inline int read()
{
int f=1,x=0;char ch=getchar();
while(ch>‘9‘|ch<‘0‘)
{
if(ch==‘-‘)
f=-1;
ch=getchar();
}
while(ch<=‘9‘&&ch>=‘0‘)
{
x=(x<<3)+(x<<1)+ch-‘0‘;
ch=getchar();
}
return f*x;
}
bool isp[N];
ll pri[N],size;
void getprime(ll lim)
{
memset(isp,1,sizeof(isp));
isp[1]=0;
for(ll i=2;i<=lim;i++)
{
if(isp[i])pri[++size]=i;
for(ll j=1;j<=size&&i*pri[j]<=lim;j++)
{
isp[i*pri[j]]=0;
if(i%pri[j]==0)break;
}
}
}
int main()
{
ll n=read(),m=read();
getprime(n);
for(int i=1;i<=m;i++)
{
ll a=read();
if(isp[a])printf("Yes\n");
else printf("No\n");
}
}
标签:ret its names char stream class int logs size
原文地址:http://www.cnblogs.com/tsunderehome/p/7517280.html