Accepted
代码
#include <iostream>
#include <string.h>
using namespace std;
const int Maxsize = 1000;
int main(void)
{
int maps[Maxsize];
memset(maps, 0, sizeof(maps));
int num, people;
cin >> num >> people;
int i, j = 2;
while (j <= people)
{
for (i = 0; i < num; i++)
{
if ((i + 1) % j == 0)
{
if (maps[i] == 0)
{
maps[i] = 1;
}
else if (maps[i] == 1)
{
maps[i] = 0;
}
}
}
j++;
}
for (i = 0; i < num; i++)
{
if (maps[i] == 0)
{
cout << i + 1 << " ";
}
}
system("pause");
return 0;
}