youtao233 @ 2024-10-19 18:31:00
#include<iostream>
#include<math.h>
using namespace std;
int aa(int a){
int s=0;
int k=a;
while(a!=0){
s=s*10+a%10;
a=a/10;
}
if(k==s){
return 0;
}else{
return 1;
}
}
int bb(int a){
for(int j=2;j<=sqrt(a);j++){
if(a%j==0){
return 1;
}else{
return 0;
}
}
}
int main(){
int a,b;
cin>>a>>b;
for(int i=a;i<=b;i++){
if(aa(i)==0&&bb(i)==0){
cout<<i<<endl;
}
}
return 0;
}
by woshnd @ 2024-10-19 19:08:43
#include<iostream>
#include<math.h>
using namespace std;
int aa(int a){
int s=0;
int k=a;
while(a!=0){
s=s*10+a%10;
a=a/10;
}
if(k==s){
return true;
}
else{
return false;
}
}
int bb(int a){
for(int j=2;j*j<=a;j++){
if(a%j==0){
return false;
}
}
return true;
}
int main(){
int a,b;
cin>>a>>b;
for(int i=a;i<=b;i++){
if(aa(i)&&bb(i)){
cout<<i<<endl;
}
}
return 0;
}
by woshnd @ 2024-10-19 19:09:33
好像最后一个超时
by youtao233 @ 2024-10-19 21:37:09
@woshnd 感谢,关了