You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
847 B

#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int a[5001] = {0};
//全部开启N盏灯
for (int i = 1; i <= N; ++i) {
a[i] = 1;
}
//模拟每一个人
for (int i = 1; i <= M; ++i) {
for (int j = 1; j <= N; ++j) {
if (j % i == 0) {
a[j] = abs(a[j] - 1);
}
}
}
//输出
string result = "";
for (int i = 1; i <= N; ++i) {
if (a[i] == 0) {
//数字转字符串
stringstream ss;
ss << i;
string str = ss.str();
//拼接结果
result += str + ",";
}
}
if (result.length() > 0) result = result.substr(0, result.length() - 1);
cout << result << endl;
return 0;
}