zlzlzlzlzl_ @ 2024-12-08 11:21:46
SOS
#include <stdio.h>
int main() {
int n, m, i, j, temp, reverse, flag1, flag2;
scanf("%d %d", &n, &m);
for (i = n; i <= m; i++) {
flag1 = 1;
if (i <= 1) {
flag1 = 0;
} else {
for (j = 2; j * j <= i; j++) {
if (i % j == 0) {
flag1= 0;
break;
}
}
}
reverse = 0;
temp = i;
flag2 = 1;
while (temp != 0) {
reverse = reverse * 10 + temp % 10;
temp /= 10;
}
if (reverse != i) {
flag2= 0;
}
if (flag1&&flag2) {
printf("%d\n", i);
}
}
return 0;
}
by ckn0915 @ 2024-12-11 08:14:44
#include<bits/stdc++.h>
using namespace std;
int c(int b){
int a=1;
int smu=0,ans=0;
for(int i=b;i>0;i=i/10) {ans=ans*10;ans=ans+i%10;}
if(ans!=b) return 0;
if(b==1) return 0;
for(int i=2;i*i<=b;i++){
if(b%i==0) return 0;
}
return 1;
}
int main(){
int a,b;
cin>>a>>b;
for(int i=a;i<=b;i++){
if(c(i)==1) cout<<i<<endl;
}
return 0;
}
@zlzlzlzlzl_