MorningStarCzy @ 2023-03-19 17:26:03
一直卡在66分上不去,这TMD咋搞???
#include<bits/stdc++.h>
using namespace std;
bool sushu(int n){
for(int i=2;i*i<=n;i++)
if(n%i==0) return false;
return true;
}
bool huiwen(int n){
if(sushu(n)==false) return false;
int t=0,m=n;
while(m){
t=t*10+m%10;
m/=10;
}
return t==n;
}
int changdu(int n){
int ans=0;
while(n>9){
n/=10;
ans++;
}
return ans;
}
int main(){
int n,m;
cin>>n>>m;
if(n%2==0) n++;
for(int i=n;i<=m;i+=2){
if(changdu(i)%2==0&&changdu(i)!=2) continue;
if(huiwen(i)) cout<<i<<endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
bool sushu(int n){
for(int i=2;i*i<=n;i++)
if(n%i==0) return false;
return true;
}
bool huiwen(int n){
if(sushu(n)==false) return false;
int t=0,m=n;
while(m){
t=t*10+m%10;
m/=10;
}
return t==n;
}
int changdu(int n){
int ans=0;
while(n>9){
n/=10;
ans++;
}
return ans;
}
int main(){
int n,m;
cin>>n>>m;
if(n%2==0) n++;
for(int i=n;i<=m;i+=2){
if(changdu(i)%2==0&&changdu(i)!=2) continue;
if(huiwen(i)) cout<<i<<endl;
}
return 0;
}
by iterator_traits @ 2023-03-19 17:29:00
@chizhuoyang 看看题目的提示可能就会了
by hezelina @ 2023-03-23 18:55:57
for(int i=a;i<=b;i+=2) { if(hui(i)==1) { if(su(i)==1) printf("%d\n",i); } } 这样输出,根据提示1