#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; string c; cin >> c; int z[2] = {0,0}; for (int i=0;i<n*8;i++) z[c[i]-48]++; z[1] -= 2*n; if (z[1]<n || z[1]>4*n) cout << "NIE"; else { string s="",codes=" acgo"; int w = z[1]/n; int r = z[1]-w*n; //cout << w << " " << r << endl; for (int i=0;i<n;i++) { char a = codes[w+(i<r)]; s += a; } cout << s; } 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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; string c; cin >> c; int z[2] = {0,0}; for (int i=0;i<n*8;i++) z[c[i]-48]++; z[1] -= 2*n; if (z[1]<n || z[1]>4*n) cout << "NIE"; else { string s="",codes=" acgo"; int w = z[1]/n; int r = z[1]-w*n; //cout << w << " " << r << endl; for (int i=0;i<n;i++) { char a = codes[w+(i<r)]; s += a; } cout << s; } return 0; } |