#include <bits/stdc++.h> using namespace std; char num_to_char(int n){ char c; switch(n){ case 3: c = 'a'; break; case 4: c = 'e'; break; case 5: c = 'm'; break; case 6: c = 'o'; break; } return c; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; string s; cin>>s; string ans=""; int ones{0}; int full{n*8}; int mi{3*n}, mx{6*n}; for(auto i : s){ if(i=='1') ones++; } if(ones > mx || ones < mi) { cout<<"NIE"; return 0; } while(n){ int minus = (ones/n + (ones%n ? 1 : 0)); ans+=num_to_char(minus); ones-= minus; n--; } cout<<ans; return 0; }
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 | #include <bits/stdc++.h> using namespace std; char num_to_char(int n){ char c; switch(n){ case 3: c = 'a'; break; case 4: c = 'e'; break; case 5: c = 'm'; break; case 6: c = 'o'; break; } return c; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; string s; cin>>s; string ans=""; int ones{0}; int full{n*8}; int mi{3*n}, mx{6*n}; for(auto i : s){ if(i=='1') ones++; } if(ones > mx || ones < mi) { cout<<"NIE"; return 0; } while(n){ int minus = (ones/n + (ones%n ? 1 : 0)); ans+=num_to_char(minus); ones-= minus; n--; } cout<<ans; return 0; } |