#include <bits/stdc++.h> using namespace std; void debug(){cerr<<"\n";} template <typename H, typename... T> void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);} #define deb(x...) cerr<<#x<<" = ";debug(x); void solve() { //3 - a, 4 - e, 5 - k, 6 - w int n; cin >> n; string s; cin >> s; int one = 0; int zero = 0; for(auto a : s) { if(a == '0') zero++; else one++; } vector <char> vec(4); vec[0] = 'a'; vec[1] = 'e'; vec[2] = 'k'; vec[3] = 'w'; long double avarage = 1.0 * one / n; if(avarage >= 3 and avarage <= 6) { int num = avarage; long double rest = 1.0 * (avarage - num) * n; for(int i = 0;i < n-rest; i++) { cout << vec[num-3]; } for(int i = 0;i < rest; i++) { cout << vec[num-2]; } } else { cout << "NIE"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; //cin >> tt; for(int case_num = 1; case_num <= tt; case_num++){ //cout << "Case #" << case_num << ": "; solve(); cout << "\n"; } 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 49 50 51 52 53 54 55 | #include <bits/stdc++.h> using namespace std; void debug(){cerr<<"\n";} template <typename H, typename... T> void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);} #define deb(x...) cerr<<#x<<" = ";debug(x); void solve() { //3 - a, 4 - e, 5 - k, 6 - w int n; cin >> n; string s; cin >> s; int one = 0; int zero = 0; for(auto a : s) { if(a == '0') zero++; else one++; } vector <char> vec(4); vec[0] = 'a'; vec[1] = 'e'; vec[2] = 'k'; vec[3] = 'w'; long double avarage = 1.0 * one / n; if(avarage >= 3 and avarage <= 6) { int num = avarage; long double rest = 1.0 * (avarage - num) * n; for(int i = 0;i < n-rest; i++) { cout << vec[num-3]; } for(int i = 0;i < rest; i++) { cout << vec[num-2]; } } else { cout << "NIE"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; //cin >> tt; for(int case_num = 1; case_num <= tt; case_num++){ //cout << "Case #" << case_num << ": "; solve(); cout << "\n"; } return 0; } |