40分 求助!!!!!4ac,3tle,其他WA
查看原帖
40分 求助!!!!!4ac,3tle,其他WA
1353245
qylftsq楼主2024/8/15 10:39
#include<bits/stdc++.h>
using namespace std;
bool ip(int a){
	if(a==1) return false;
	for(int i=2;i<=sqrt(a);i++){
		if(a%i==0) return false;
	}
	return true;
}
int main(){
	int n,m,l,r;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>l>>r;
		if(r>m) cout<<"Crossing the line"<<endl;
		else {
			int ans=0;
			for(int j=l;j<=r;j++){
				if(ip(j)==1) ans++;
			}
			cout<<ans<<endl;
		} 
	}
	return 0;
}

2024/8/15 10:39
加载中...