题目就是让你输出n个数的序列,要保证该序列是递增的,并且第i个数的前面不能保护它的约数,我直接先对前100000的素数打表,然后输出前n个,so easy。
//cf 191 B
#include <stdio.h>
#include <string.h>
int ans[100005]; bool vis[10000000];
int main()
{
int cnt = 1;
for (int i = 2; i < 1300000; i++)
{
if (vis[i])
continue;
for (int j = i+i; j < 10000000; j += i)
vis[j] = true;
if (!vis[i])
ans[cnt++] = i;
if (cnt > 100000)
{
break;
}
}
int n;
while (scanf("%d", &n) != EOF)
{
for (int i = 1; i < n; i++)
printf("%d ", ans[i]);
printf("%d\n", ans[n]);
}
return 0;
}