#include <iostream> using namespace std; int n; char c; int bits; char letters[7] = {'\0', '\0', '\0', 'a', 'c', 'g', 'o'}; int main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin >> n; for(int i=0;i<8*n;i++){ cin >> c; if(c == '1') bits++; } if(bits < 3*n || bits > 6*n){ cout << "NIE"; return 0; } //cout << bits << "\n"; int k = 3; while(bits > k*n) k++; k--; int l = bits - k*n; for(int i=0;i<l;i++){ cout << letters[k+1]; } for(int i=0;i<n-l;i++){ cout << letters[k]; } 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 | #include <iostream> using namespace std; int n; char c; int bits; char letters[7] = {'\0', '\0', '\0', 'a', 'c', 'g', 'o'}; int main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin >> n; for(int i=0;i<8*n;i++){ cin >> c; if(c == '1') bits++; } if(bits < 3*n || bits > 6*n){ cout << "NIE"; return 0; } //cout << bits << "\n"; int k = 3; while(bits > k*n) k++; k--; int l = bits - k*n; for(int i=0;i<l;i++){ cout << letters[k+1]; } for(int i=0;i<n-l;i++){ cout << letters[k]; } return 0; } |