3个TLE为啥
查看原帖
3个TLE为啥
1048576
yanghaoyu123楼主2025/1/20 22:42
#include <bits/stdc++.h>
using namespace std;
int isPrime(int x){
    for (int i=3;i<=sqrt(x);i++){
        if (x%i==0){
            return false;
        }
    }
    return true;
}
int huiwen(int s){
    int s2=0;
    int n=s;
    while (s>0){
        s2=s2*10+s%10;
        s/=10;
    }
    if (n==s2){
        return true;
    }
    else{
        return false;
    }
}
int main(){
    int a,b;
    cin>>a>>b;
    if (a%2==0){
        a++;
    }
    for (int i=a;i<=b;i+=2){
        if (isPrime(i) && huiwen(i)){
            cout<<i<<'\n';
        }
    }
    return 0;
}

2025/1/20 22:42
加载中...