// by KR zaklucenia [zak] c #include <iostream> #include <vector> #include <string> using namespace std; int main() { double n; string ciag, wynik; cin >> n >> ciag; int one = 0, dl = n; for (int i = 0; i < 8 * n; i++) { if (ciag[i] == '1') { one++; } } while (one / n > 5) { wynik+="o"; one -= 6; n--; } while (one / n > 4) { wynik += "g"; one -= 5; n--; } while (one / n > 3) { wynik += "c"; one -= 4; n--; } while (one / n > 2) { wynik += "a"; one -= 3; n--; } if (wynik.length() != dl) { cout << "NIE"; return 0; } cout << wynik; 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 | // by KR zaklucenia [zak] c #include <iostream> #include <vector> #include <string> using namespace std; int main() { double n; string ciag, wynik; cin >> n >> ciag; int one = 0, dl = n; for (int i = 0; i < 8 * n; i++) { if (ciag[i] == '1') { one++; } } while (one / n > 5) { wynik+="o"; one -= 6; n--; } while (one / n > 4) { wynik += "g"; one -= 5; n--; } while (one / n > 3) { wynik += "c"; one -= 4; n--; } while (one / n > 2) { wynik += "a"; one -= 3; n--; } if (wynik.length() != dl) { cout << "NIE"; return 0; } cout << wynik; return 0; } |