123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <stdio.h>
- #include <math.h>
- int is_prime(int x) {
- int i;
- if (x <= 1) {
- return 0;
- }
- for (i = 2; i <= sqrt(x); ++i) {
- if (x % i == 0) {
- return 0;
- }
- }
- return 1;
- }
- int absolute(int x) {
- int reverse = 0, original = x;
- while (x > 0) {
- int digit = x % 10;
- reverse = reverse * 10 + digit;
- x /= 10;
- }
- return is_prime(original) && is_prime(reverse);
- }
- int main() {
- int a, b,i;
- scanf("%d %d", &a, &b);
- for (i = a; i <= b; ++i) {
- if (absolute(i)) {
- printf("%d\n", i);
- }
- }
- return 0;
- }
|