some programs!

This commit is contained in:
rogerwang2008 committed 2026-09-25 20:20:01 +08:00
1 parent 5d30e847c1
commit ed054247d5
32 files changed
+1882 -149

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;
}