some programs!
This commit is contained in:
1 parent
5d30e847c1
commit
ed054247d5
32 files changed
+1882
-149
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user