Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
353662 | 胡珂 | 【C6-10】回文质数 Prime Palindromes | C++ | Accepted | 100 | 374 MS | 10036 KB | 572 | 2025-09-30 20:16:04 |
#include<bits/stdc++.h> using namespace std; int n,m; const int N=1e8+10; bool f[N]; bool huiwen(int n){ string s=""; while(n){ s=char(n%10+'0')+s; n/=10; } string s2=s; reverse(s2.begin(),s2.end()); if(s==s2) return true; return false; } int main(){ int k=0; cin>>n>>m; if(m>10000000) m=10000000; f[0]=f[1]=1; for(int i=2;i<=sqrt(m);i++) if(!f[i]) for(int j=2*i;j<=m;j+=i) f[j]=1; for(int i=n;i<=m;i++){ if(!f[i]){ if(huiwen(i)){ k=1; cout<<i<<endl; } } } if(!k) cout<<"NO"; return 0; }