0分,全TLE求调
查看原帖
0分,全TLE求调
1634119
zhclg2014楼主2025/7/26 18:15
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int n;
bool prime[100000000];
void pre(){
	memset(prime,1,sizeof(prime));
	prime[1]=0;
	for(int i=2;i<=100000000;i++){
		if(prime[i]){
			int tmp=i;
			for(int j=tmp*2;j<=100000000;j+=tmp){
				prime[j]=0;
			}
		}
	}
}
bool hw(int b){
    int B=b;
	int wei=0;
	while(b>0){
		wei=wei*10+b%10;
		b/=10;
	}
	if(wei==B)return true;
    else return false;
}
int main(){
    int n,m;
    cin>>n>>m;
    pre();
    for(int i=n;i<=m;i++){
        if(i%2==0)continue;
        if(prime[i]&&hw(i))cout<<i<<endl;
    }
    return 0;
}
2025/7/26 18:15
加载中...