66分求助!!
查看原帖
66分求助!!
505918
SakLanS楼主2021/8/1 11:08
#include<bits/stdc++.h>
using namespace std;
bool sushu(int x){
	if(x%2==0) return false;
	int flag=x;
	int flag2=0;
	while(x!=0){
		flag2=flag2*10+x%10;
		x/=10;
	}
	if(flag2!=flag) return false;
	x=flag;
	for(int i=3;i<x/2+1;i+=2)
	if(x%i==0) return false;
	return true;
}
int main(){
	ios::sync_with_stdio(false),cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	int tt=0,ans[1001],total=0;
	for(int i=a;i<=b;i++){
		if(sushu(i)){
			cout<<i<<endl;
		}
	}
}

代码如上,最后三点TLE,不知道怎么可以再缩了,求求了,帮帮娃子吧:D

2021/8/1 11:08
加载中...