Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
312604 | admin_wgf | 【C6-10】回文质数 Prime Palindromes | C++ | 通过 | 100 | 172 MS | 10024 KB | 572 | 2025-03-15 09:43:50 |
#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; }