40 lines
685 B
C++
40 lines
685 B
C++
|
#include <cstring>
|
||
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
int sushu(int n)
|
||
|
{
|
||
|
if(n==1){
|
||
|
return 0;
|
||
|
}
|
||
|
for (int i = 2; i * i <= n; i++) {
|
||
|
if (n % i == 0) {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
return 1;
|
||
|
}
|
||
|
int huiwen(string n)
|
||
|
{
|
||
|
int len = n.size() - 1;
|
||
|
for (int i = 0; i <= len / 2; i++) {
|
||
|
if (n[i] != n[len - i]) {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
int s = 0;
|
||
|
for (int i = n.size() - 1; i >= 0; i--) {
|
||
|
s *= 10;
|
||
|
s += n[i]-'0';
|
||
|
}
|
||
|
return sushu(s);
|
||
|
}
|
||
|
int main()
|
||
|
{
|
||
|
int ans = 0;
|
||
|
string n;
|
||
|
while (cin >> n) {
|
||
|
ans += huiwen(n);
|
||
|
}
|
||
|
cout<<ans;
|
||
|
}
|