最后3点超时啊!求解
查看原帖
最后3点超时啊!求解
1539028
dingjingxuan1234楼主2024/10/25 19:09
#include <bits/stdc++.h>
using namespace std;
bool zhishu(int zs){
	for(int i=2;i<=sqrt(zs);i++){
		if(zs%i==0){
			return 0;
		}
	}
	if(zs>1){
		return 1;
	}
}
bool huiwenshu(int hws){
	int h=0,y=hws;
	while(hws){
		h=h*10+hws%10;
		hws=hws/10;
	}
	if(h==y){
		h=0;
		return 1;
	}
	h=0;
	return 0;
}
int main(){
	int a,b;
	cin>>a>>b;
	for(int j=a;j<=b;j++){
		if(zhishu(j)==1&&huiwenshu(j)==1){
			cout<<j<<"\n";
		}
	}
    return 0;
}

2024/10/25 19:09
加载中...