ZBXALQX @ 2023-12-28 19:12:39
#include<bits/stdc++.h>
using namespace std;
bool is_p(int x){
for(int i=2;i<=sqrt(x);i++)
if(x%i==0) return 0;
return 1;
}
bool hw(int x){
if(x/100==x%10)return 1;
else return 0;
}
int main(){
int i,j;
cin>>i>>j;
for(i=1;i<=j;i++){
if(is_p(i)&&hw(i))
cout<<i<<endl;
}
return 0;
}
by ZBXALQX @ 2023-12-28 19:17:25
十万火急!!!在线等
by ZBXALQX @ 2023-12-28 19:43:19
@GXZJQ 我看不到你的回复啊
by SkyWave @ 2023-12-28 19:50:38
@ZBXALQX 偷懒的写法就是你可以先把数字转成字符串,判断反转后的和反转前的字符串相不相等就好了
by SkyWave @ 2023-12-28 19:51:40
bool check(int num) {
string str = to_string(num);
string rev = str;
reverse(rev.begin(), rev.end());
return str == rev;
}
by ChenDibang @ 2024-01-24 17:25:29
@SkyWave 超时