#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define ll long long vector <int> v; string s; int n, ile, ile3, ile4, ile5, ile6; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> s; for(int i = 0; i < s.size(); i++) ile += (s[i] == '1'); ile3 = ile / 3; ile %= 3; if(ile) ile3--; if(ile == 1) ile4++; if(ile == 2) ile5++; while(ile3+ile4+ile5+ile6 > n && ile3 >= 2) { if(!ile3) { cout<< "NIE\n"; return 0; } ile6++, ile3 -= 2; } if(ile3+ile4+ile5+ile6 != n) { cout<< "NIE\n"; return 0; } while(ile6--) cout << 'o'; while(ile5--) cout << 'n'; while(ile4--) cout << 'l'; while(ile3--) cout << 'h'; cout << "\n"; }
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 | #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define ll long long vector <int> v; string s; int n, ile, ile3, ile4, ile5, ile6; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> s; for(int i = 0; i < s.size(); i++) ile += (s[i] == '1'); ile3 = ile / 3; ile %= 3; if(ile) ile3--; if(ile == 1) ile4++; if(ile == 2) ile5++; while(ile3+ile4+ile5+ile6 > n && ile3 >= 2) { if(!ile3) { cout<< "NIE\n"; return 0; } ile6++, ile3 -= 2; } if(ile3+ile4+ile5+ile6 != n) { cout<< "NIE\n"; return 0; } while(ile6--) cout << 'o'; while(ile5--) cout << 'n'; while(ile4--) cout << 'l'; while(ile3--) cout << 'h'; cout << "\n"; } |