一个点TLE 呜呜呜
代码如下:
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x)
{
if(x == 1) return false;
for(int i = 2;i * i <= x;++i)
{
if(x % i == 0) return false;
}
return true;
}
bool isPal(int x){
int y = x;
int z = 0;
while(y)
{
z = z * 10 + y % 10;
y /= 10;
}
if(x == z) return true;
else return false;
}
int main()
{
int a,b;
cin >> a >> b;
for(int i = a;i <= b;++i)
{
if(isPal(i) && isPrime(i))
{
cout << i << endl;
}
}
return 0;
}
求求了救救本蒟蒻扒吧!