Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
39596 | 超人JAX | 真素数 | C++ | 通过 | 100 | 39 MS | 10492 KB | 627 | 2023-05-27 21:03:33 |
#include <iostream> #include <cstring> using namespace std; bool prime[10000005]; void era(int n){ memset(prime,0,sizeof(prime)); prime[0]=1; prime[1]=1; for(int i=2;i<=n;i++){ if(!prime[i]){ for(int j=i*2;j<=n;j+=i){ prime[j]=1; } } } return; } bool check(int n){ int res=0,tp=n; while(tp){ res=res*10+tp%10; tp/=10; } if(!prime[n]&&!prime[res]){ return 1; }else{ return 0; } } int main(){ int a,b; cin>>a>>b; era(5000000); bool f=0; for(int i=a;i<=b;i++){ if(check(i)){ cout<<i<<" "; f=1; } } if(!f){ cout<<"No"; } return 0; }