66分求调。(我不会打表,算法,素数筛法)
查看原帖
66分求调。(我不会打表,算法,素数筛法)
1088916
wangxiangquan楼主2024/8/7 18:26
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,f;
    scanf("%lld %lld",&a,&b);
    if(a%2==0) a++;
    for(int i=a;i<=b;i+=2)
    {
        f=1;
        if(i%2==0) continue;
        for(int j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=0;
                break;
            }
        }
        if(f==1)
        {
            int s=0,x=i;
            while(x!=0)
            {
                s=s*10+x%10;
                x=x/10;
            }
            if(s==i) printf("%d\n",i);
        }
    }
    return 0;
}
2024/8/7 18:26
加载中...