hzoi_Shadow @ 2023-04-16 11:04:23
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x)
{
int i;
for(i=3;i<=sqrt(x);i+=2)
{
if(x%i==0)
{
return false;
}
}
return true;
}
bool huiwen(int n)
{
int num=0,sum=0,cnt=n;
while(cnt>0)
{
num++;
cnt/=10;
}
cnt=n;
if(num%2==1)
{
while(cnt>0)
{
sum*=10;
sum+=cnt%10;
cnt/=10;
}
if(sum==n)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
int main()
{
int a,b,ans=0,i;
cin>>a>>b;
if(a<=2)
{
printf("2\n");
}
if(a%2==0)
{
a++;
}
for(i=a;i<=b;i+=2)
{
if(isprime(i)==true&&huiwen(i)==true)
{
printf("%d\n",i);
}
}
return 0;
}
by hzoi_Shadow @ 2023-04-16 11:25:20
这是目前的,66pts,T了最后三个点
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x)
{
int i;
if(x==1)
{
return false;
}
else
{
for(i=3;i<=sqrt(x);i+=2)
{
if(x%i==0)
{
return false;
}
}
return true;
}
}
bool huiwen(int n)
{
int num=0,sum=0,cnt=n;
while(cnt>0)
{
num++;
sum*=10;
sum+=cnt%10;
cnt/=10;
}
if((num==2||num%2==1)&&sum==n)
{
return true;
}
else
{
return false;
}
}
int main()
{
int a,b,i;
cin>>a>>b;
if(a<=2)
{
printf("2\n");
}
if(a%2==0)
{
a++;
}
for(i=a;i<=b;i+=2)
{
if(isprime(i)==true&&huiwen(i)==true)
{
printf("%d\n",i);
}
}
return 0;
}
by wkh2008 @ 2023-04-16 11:27:12
@The_Shadow_Dragon 但凡看看提示
by hzoi_Shadow @ 2023-04-16 11:27:49
@wkh2008 az
by hzoi_Shadow @ 2023-04-16 11:37:35
@wkh2008 换了个顺序AC了