RE 求助
查看原帖
RE 求助
712337
XYQ_102楼主2024/1/5 18:15
#include<bits/stdc++.h>
using namespace std;
bool isPrime[100000005]={false};
void Eratosthenes()
{
	for(int i=2;i<=100000000;i++)
		if(!isPrime[i])
			for(int j=i*2;j<=100000000;j+=i)
				isPrime[j]=true;
} 
int main()
{
	Eratosthenes();
	int T;
	cin>>T;
	for(int i=1;i<=T;i++)
	{
		int a,b,ans=0;
		cin>>a>>b;
		for(int j=a;j<=b;j++)
			if(isPrime[j]==false && (isPrime[j*j+1]==false || isPrime[j*j+2]==false))
				ans++;
		cout<<ans<<"\n";
	}
	return 0;
}

Runtime Error.SIGSEGV

2024/1/5 18:15
加载中...