题解 | #素数回文#
素数回文
http://www.nowcoder.com/practice/d638855898fb4d22bc0ae9314fed956f
#include<math.h>
int output(long n) {
int count = 2;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) count++;
if (count != 2) break;
}
if (count == 2) return count;
else return 0;
}
int main() {
long n = 0, m = 0;
scanf("%d", &n);
if (output(n) == 2) {
m = n / 10;
while (m) {
n = n * 10 + m % 10;
m /= 10;
}
if (output(n) == 2) printf("prime");
else printf("noprime");
} else printf("noprime");
return 0;
}