#include <iostream> using namespace std; int main() { string s; int n; int j = 0; cin >> n; cin >> s; for(int i = 0; i < 8*n; i++) { if(s[i] == '1')j++; } if(j < 3 * n) { cout << "NIE"; return 0; } if(j > 6 * n) { cout << "NIE"; return 0; } int r = j % n; int dz = j / n; for(int i = 0; i < n; i++) { int dod = 0; if(r > 0) { dod++; r--; } if(dz + dod == 3)cout << "a"; if(dz + dod == 4)cout << "c"; if(dz + dod == 5)cout << "g"; if(dz + dod == 6)cout << "p"; } }
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 | #include <iostream> using namespace std; int main() { string s; int n; int j = 0; cin >> n; cin >> s; for(int i = 0; i < 8*n; i++) { if(s[i] == '1')j++; } if(j < 3 * n) { cout << "NIE"; return 0; } if(j > 6 * n) { cout << "NIE"; return 0; } int r = j % n; int dz = j / n; for(int i = 0; i < n; i++) { int dod = 0; if(r > 0) { dod++; r--; } if(dz + dod == 3)cout << "a"; if(dz + dod == 4)cout << "c"; if(dz + dod == 5)cout << "g"; if(dz + dod == 6)cout << "p"; } } |