无输出求救

P1217 [USACO1.5] 回文质数 Prime Palindromes

goodwepb1 @ 2024-10-09 21:46:08

#include<bits/stdc++.h>
using namespace std;
int huiwen(int s)
{
    int sum=1;
    while(s>0)
    {
        sum+=s%10;
        s/=10;
        sum*=10;
    }
    if(s==sum)
    return 1;
    else return 2;
}
bool prime(int a)
{
    for(int i=2;i*i<=a;i++)
    {
        if(a%i==0)
        return 1;
    }
    return 0;
}
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%2==0)
        {
        continue;
        }
        if(i%3==0)
        {
            continue;
        }
        if(i%5==0&&i!=5)
        {
            continue;
        }
        if(i%7==0&&i!=7)
        {
            continue;
        }
        if(huiwen(i)==1&&prime(i)==0)
        cout<<i<<endl;
    }
}

|