66分TLE求救
查看原帖
66分TLE求救
1360152
wanghonghui123楼主2024/7/20 12:19
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline bool isPrime(LL x){
	if(x<2) return false;
	for(LL i=2;i*i<=x;i++){
		if(x%i==0) return false;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	LL a,b;
	cin>>a>>b;
	for(LL i=a;i<=b;i++){
		string s=to_string(i);
		string t=s;
		reverse(s.begin(),s.end());
		if((isPrime(i))&&(s==t)){
			cout<<i<<endl;
		}	
	}
	return 0;
}
2024/7/20 12:19
加载中...