#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int zer = 0; int jed = 0; for (char x : s) { if (x =='0')zer++; if (x=='1')jed++; } string w; while (zer + jed >=8) { if (jed < zer) { jed -= 3; zer -= 5; w+='a'; continue; } if (jed == zer) { jed -=4; zer -=4; w+='e'; continue; } if (jed == 5 and zer ==3) { jed-=5; zer-=3; w+='k'; continue; } if (jed > zer) { jed-=6; zer-=2; w+='o'; continue; } } if (jed == 0 and zer ==0) cout << w << endl; else cout << "NIE"<<endl; } //4 , 3 , 5 /* 2 1100000011110111 */
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 62 63 64 65 66 67 | #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int zer = 0; int jed = 0; for (char x : s) { if (x =='0')zer++; if (x=='1')jed++; } string w; while (zer + jed >=8) { if (jed < zer) { jed -= 3; zer -= 5; w+='a'; continue; } if (jed == zer) { jed -=4; zer -=4; w+='e'; continue; } if (jed == 5 and zer ==3) { jed-=5; zer-=3; w+='k'; continue; } if (jed > zer) { jed-=6; zer-=2; w+='o'; continue; } } if (jed == 0 and zer ==0) cout << w << endl; else cout << "NIE"<<endl; } //4 , 3 , 5 /* 2 1100000011110111 */ |