66分求调!3个TLE!玄关
查看原帖
66分求调!3个TLE!玄关
1028387
chenkuan_001楼主2024/8/24 16:14

代码

#include<bits/stdc++.h>
using namespace std;
int check(int a){
	int s[15];
	for(int i=2;i*i<=a;i++){
		if(a%i==0){
			return 0;
		}
	}
	int lc=0;
	while(a!=0){
		lc++;
		s[lc]=a%10;
		a/=10;
	}
	for(int i=1;i<=lc/2;i++){
		if(s[i]!=s[lc-i+1]){
			return 0;
		}
	}
	return 1;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(check(i)==1){
			cout<<i<<endl;
		}
	}
	return 0;
}
2024/8/24 16:14
加载中...