#include <iostream> using namespace std; int main() { int n; cin >> n; int one = 0, zero = 0; char value; for (int i = 0; i < 8 * n; i++) { cin >> value; if (value == '1') one++; else zero++; } int znak = one / n; int wiekszy = one % n; if (one < 3 * n || one > 6*n) cout << "NIE"; else { for (int i = 0; i < wiekszy; i++) { switch (znak + 1) { case 4: cout << "c"; break; case 5: cout << "g"; break; case 6: cout << "o"; break; } } for (int i = 0; i < n - wiekszy; i++) { switch (znak) { case 3: cout << "a"; break; case 4: cout << "c"; break; case 5: cout << "g"; break; case 6: cout << "o"; break; } } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #include <iostream> using namespace std; int main() { int n; cin >> n; int one = 0, zero = 0; char value; for (int i = 0; i < 8 * n; i++) { cin >> value; if (value == '1') one++; else zero++; } int znak = one / n; int wiekszy = one % n; if (one < 3 * n || one > 6*n) cout << "NIE"; else { for (int i = 0; i < wiekszy; i++) { switch (znak + 1) { case 4: cout << "c"; break; case 5: cout << "g"; break; case 6: cout << "o"; break; } } for (int i = 0; i < n - wiekszy; i++) { switch (znak) { case 3: cout << "a"; break; case 4: cout << "c"; break; case 5: cout << "g"; break; case 6: cout << "o"; break; } } } } |