11分!求整!!

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

lijunxian_0818_2 @ 2024-08-28 23:51:54

传送门


by lijunxian_0818_2 @ 2024-08-28 23:53:01

@Mysterious_Man 按我的代码 大佬们尽量按我的代码改!谢谢!


by hyl_____ @ 2024-08-28 23:59:35

@Mysterious_Man @Mysterious_Man @Mysterious_Man @Mysterious_Man 你的换行要接着 i 后输出,不然会多出亿个换行


by hyl_____ @ 2024-08-28 23:59:56

#include<bits/stdc++.h>
using namespace std;
long long a,b;
bool ss(int n){
    if(n<2) return 0;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0) return 0;
    }
    return 1;
} 
bool hws(int n){
    int s=0,m=n;
    while(m){
        s=s*10+m%10;
        m/=10;
    }
    return n==s;
}
int main()
{
    scanf("%lld%lld",&a,&b);
    for(int i=a;i<=b;i++)
    {
        if(i%2==0 || i%3==0 || i%10==0) continue;
        if(hws(i)){
            if(ss(i))   cout<<i<<endl;
            /*cout<<' ';*/
        }

    }
    return 0;
}

by lijunxian_0818_2 @ 2024-08-29 00:00:16

@hyl_____

明白了!谢谢!已关!


by hyl_____ @ 2024-08-29 00:00:48

no thx


|