123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <stdio.h>
- int isPrime(int num) {
- int i;
- if (num <= 1) {
- return 0;
- }
- for (i = 2; i * i <= num; i++) {
- if (num % i == 0) {
- return 0;
- }
- }
- return 1;
- }
- int isReversiblePrime(int num) {
- int reversedNum = 0;
- int originalNum = num;
- while (num > 0) {
- reversedNum = reversedNum * 10 + num % 10;
- num /= 10;
- }
- return isPrime(reversedNum) && isPrime(originalNum);
- }
- int main() {
- int num;
- scanf("%d", &num);
- if (isReversiblePrime(num)) {
- printf("yes\n");
- } else {
- printf("no\n");
- }
- return 0;
- }
|