文章
81
粉丝
2
获赞
494
访问
9.5k
#include <iostream>
using namespace std;
bool isPrime(int x){
if(x < 2) return false;
for(int i = 2; i * i <= x; i++){
if(x % i == 0)
return false;
}
return true;
}
int main(){
int n;
while(cin >> n){
bool res = true;
for(int i = 1; i < n; i++){
if(isPrime(i) && i%10==1){
if(!res) cout << ' ';
cout << i;
res = false;
}
}
if(res)
cout << -1;
cout << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发