超时了,哪个大佬带带我

P1217 [USACO1.5] 回文质数 Prime Palindromes

zxhiding @ 2022-10-11 20:15:54

#include<stdio.h>
int con(int x) {
    int a = 0;
    int y = x;
    while (y != 0) {
        a = a * 10 + y%10;
        y /= 10;
    }if (a == x) {
        return 1;
    }
    else return 0;
}
int main() {
    int a,b,c=0;
    scanf("%d %d", &a,&b);
    for (int i = a; i <= b; i++) {
        for (int k = 2; k < i; k++) {
            c = i % k;
            if (c == 0) break;
        }if (c != 0 && con(i) == 1) {
            printf("%d\n", i);
        }
    }
    return 0;
    }

by Kniqht @ 2022-10-11 20:21:11

@zxhiding 建议看题解你这·应该是方法问题


|