#include <iostream> using namespace std; int main() { int n, a=0; char c; cin >> n; for (int i = 0; i < 8 * n; i++) { cin >> c; if ('1' == c)a++; } if (a < 3 * n || a > 6 * n) { cout << "NIE"; return 0; } a -= 3 * n; for (; a >= 3; a -= 3, n--) { cout << "w"; } for (; n > 1; n--) { cout << "a"; } if (0 == a && 1 == n)cout << "a"; if (1 == a)cout << "c"; if (2 == a)cout << "g"; }
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 | #include <iostream> using namespace std; int main() { int n, a=0; char c; cin >> n; for (int i = 0; i < 8 * n; i++) { cin >> c; if ('1' == c)a++; } if (a < 3 * n || a > 6 * n) { cout << "NIE"; return 0; } a -= 3 * n; for (; a >= 3; a -= 3, n--) { cout << "w"; } for (; n > 1; n--) { cout << "a"; } if (0 == a && 1 == n)cout << "a"; if (1 == a)cout << "c"; if (2 == a)cout << "g"; } |