这题贼简单

就是写起来麻烦

直接枚举每个位数就行

蒟蒻表示搜索什么不存在的,暴力天下第一

顺便本蒟蒻数学一般...不明白为什么4,6,8位回文质数为何不存在就一起枚举了

具体看代码```cpp

include<iostream>

include<cmath>//平方根函数sqrt的头文件

using namespace std;

int check(int x)

{

for(int i=2;i<=sqrt(x);i++)

{

 if(x%i==0)

 {

    return 0;//判断质数..不多解释了

 }

}

return 1;

}

int main()

{

int l,r;

cin>>l>>r;

for(int g=2;g<=9;g++)//个位

{

    int x=g;

    if(x>=l&&x<=r&&check(x)==1)

        {

            cout<<x<<endl;

        }

}

for(int s=1;s<=9;s+=2)//因为质数结尾不可能是偶数所以加2

{

     int x=s*10+s;

        if(x>=l&&x<=r&&check(x)==1)

        {

            cout<<x<<endl;

        }

  }

for(int b=1;b<=9;b+=2)

{

    for(int s=0;s<=9;s++)

    {

        int x=b*100+s*10+b;

        if(x>=l&&x<=r&&check(x)==1)//满足条件就输出

        {

            cout<<x<<endl;

        }

    }

}

for(int q=1;q<=9;q+=2)

{

    for(int b=0;b<=9;b++)

    {

        int x=q*1000+b*100+b*10+q;

        if(x>=l&&x<=r&&check(x)==1)

        {

            cout<<x<<endl;//同上

        }

    }

}

for(int w=1;w<=9;w+=2)

{

    for(int q=0;q<=9;q++)

    {

        for(int b=0;b<=9;b++)

        {

            int x=w*10000+q*1000+b*100+q*10+w;

            if(x>=l&&x<=r&&check(x)==1)

            {

              cout<<x<<endl;//同上

            }

        }

    }

}

for(int sw=1;sw<=9;sw+=2)

{

    for(int w=0;w<=9;w++)

    {

        for(int q=0;q<=9;q++)

        {

            int x=sw*100000+w*10000+q*1000+q*100+w*10+sw;

            if(x>=l&&x<=r&&check(x)==1)

            {

              cout<<x<<endl;//同上

            }

        }

    }

}

for(int bw=1;bw<=9;bw+=2)

{

    for(int sw=0;sw<=9;sw++)

    {

        for(int w=0;w<=9;w++)

        {

            for(int q=0;q<=9;q++)

            {

                int x=bw*1000000+sw*100000+w*10000+q*1000+w*100+sw*10+bw;

                if(x>=l&&x<=r&&check(x)==1)

            {

              cout<<x<<endl;//同上

            }

            }

        }

    }

}

for(int qw=1;qw<=9;qw+=2)

{

  for(int bw=0;bw<=9;bw++)

  {

      for(int sw=0;sw<=9;sw++)

      {

        for(int w=0;w<=9;w++)

        {

            int x=qw*10000000+bw*1000000+sw*100000+w*10000+w*1000+sw*100+bw*10+qw;

            if(x>=l&&x<=r&&check(x)==1)

            {

              cout<<x<<endl;//同上

            }

        }

      }

  }

}

return 0;//就结束了...