标签:span print pac ros == turn ret cross std
#include <cstdio>
#include <iostream>
using namespace std;
const int N=1000000;
int p[N],n,m,nop[N],cnt,sum,ans[N];
int main(){
scanf("%d%d",&n,&m);
nop[1]=1;
for(int i=2;i<=m;i++){
if(!nop[i]){p[++cnt]=i; sum++;}
ans[i]=sum;
for(int j=1;j<=cnt && p[i]<=i && i*p[j]<=m;j++){
nop[i*p[j]]=1;
if(i%p[j]==0)break;
}
}
while(n--){
int l,r;
scanf("%d%d",&l,&r);
if(l<1 || r>m){puts("Crossing the line"); continue;}
printf("%d\n",ans[r]-ans[l-1]);
}
return 0;
}
标签:span print pac ros == turn ret cross std
原文地址:http://www.cnblogs.com/codetogether/p/7631416.html