#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int _0 = 0; int _1 = 0; char l; for (int i = 0; i < 8*n; i++) { cin >> l; if (l == '1') _1++; else _0++; } _1 -= 3 * n; _0 -= 2 * n; if (_1 < 0 || _0 < 0) cout << "NIE"; else { while (_0 > 2) { cout << 'a'; _0 -= 3; } while (_1 > 2) { cout << 'o'; _1 -= 3; } if (_0 == 1) cout << 'm'; if (_0 == 2) cout << 'i'; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int _0 = 0; int _1 = 0; char l; for (int i = 0; i < 8*n; i++) { cin >> l; if (l == '1') _1++; else _0++; } _1 -= 3 * n; _0 -= 2 * n; if (_1 < 0 || _0 < 0) cout << "NIE"; else { while (_0 > 2) { cout << 'a'; _0 -= 3; } while (_1 > 2) { cout << 'o'; _1 -= 3; } if (_0 == 1) cout << 'm'; if (_0 == 2) cout << 'i'; } } |