6以前WA
6以后TLE
6AC
代码如下
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
string str(int n){
string s;
int i = 0;
while(n){
s[i] = n % 10;
++i;
n /= 10;
}
return s;
}
bool prime(int n){
if(n == 1 || n == 0) return false;
if(n == 2) return true;
for(int i = 2; i <= sqrt(n); ++i) if(n % i == 0) return false;
return true;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int a, b;
cin >> a >> b;
for(int i = a; i <= b; ++i){
string t1 = str(i), t2 = t1;
reverse(t1.begin(), t1.end());
if(prime(i) == true && t1 == t2)
cout << i << endl;
}
return 0;
}
求求您帮帮这个juruo吧