Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
3132 邓小龙 寻找绝对素数 C++ Accepted 6 MS 268 KB 694 2024-04-06 10:49:48

Tests(10/10):


Code:

# include<iostream> using namespace std; bool a(int n){ if(n==1||n==0)return false; for(int i=2;i<=n/i;i++){ if(n%i==0)return false; } return true; } int d(int n){ int e=0; while(n>0){ e=e*10+n%10; n/=10; } return e; } int main(){ int b,c,f[100001],g=0,h=0; cin>>b>>c; for(int i=b;i<=c;i++){ if(a(i)){ if(a(d(i))){ g=1; f[h]=i; h++; } } } if(g==0)cout<<"No"; else { for(int i=0;i<h;i++){ cout<<f[i]; if(i!=h-1)cout<<","; } } return 0; }