文章
49
粉丝
90
获赞
9
访问
27.3k
#include<cmath>
#include<iostream>
#include <vector>
using namespace std;
bool sushu(int n)
{
if (n < 2)
{
return false;
}
else
{
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
return false;
}
}
return true;
}
int main()
{
int b;
while (cin >> b)
{
vector<int> v;
int sum = 0;
for (int i = 2; i < b; i++)
{
if (sushu(i) && (i % 10 == 1))
{
sum++;
v.emplace_back(i);
}
}
if (sum == 0)
cout << -1 << endl;
else
{
for (auto i = v.begin(); i < v.end() - 1; i++)
{
cout << *i << " ";
}
cout << v.back();
}
cout << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发