#include <iostream>
#include <cmath>
using namespace std;
int s[10000];
int j = 0;
int judge(int n)
{
for(int i=2;i<=sqrt(n);i++)
{
if(n%i==0)
{
return 0;
}
}
s[j] = n; j++;
return 1;
}
int main()
{
int a,b;
cin>>a>>b;
int k = 0;
int count = 2;
while(k<b)
{
if(j==b)
{
k = b; break;
}
judge(count);
count++;
}
int next = 0;
for(int i=a-1;i<j;i++)
{
if(next==9)
{
cout<<s[i];
i++; // 1 到 10
cout<<endl;
next=0;
}
if(i==(j-1))
{
cout<<s[i];
break;
}
if(s[i]==0) // 1 到 10
{
break;
}
cout<<s[i]<<" ";
next++;
}
}
PAT 1013 数素数
最新推荐文章于 2024-07-31 21:39:59 发布