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

+39
View File
@@ -0,0 +1,39 @@
#include <iostream>
using namespace std;
constexpr int MAX_N = 151;
bool cards_flipped[MAX_N];
void simulate() {
for (int divider=2; divider<MAX_N; divider++) {
for (int i=divider; i<MAX_N; i+=divider) {
cards_flipped[i] = !cards_flipped[i];
}
}
}
void print_ans() {
int amount = 0;
bool first = true;
for (int i = 1; i < MAX_N; i++) {
if (!cards_flipped[i]) {
if (!first) cout << " ";
cout << "N" << i;
first = false;
amount++;
}
}
cout << endl << amount << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
simulate();
print_ans();
return 0;
}