some programs!!

This commit is contained in:
rogerwang2008 committed 2026-09-28 14:05:06 +08:00
1 parent ed054247d5
commit 71f1022dea
38 files changed
+1037 -281

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
#include <iostream>
constexpr int MAX_N = 1001;
int n;
bool lamps[MAX_N]; // 第 0 盏放弃
void simulate() {
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= n; j += i) {
lamps[j] = !lamps[j];
}
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> n;
simulate();
for (int i = 1; i <= n; i++) {
if (!lamps[i]) {
std::cout << i << " ";
}
}
std::cout << std::endl;
return 0;
}