#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr << #x << " " << x << endl
#define int long long
#define st first
#define nd second
using namespace std;
const int N(1e6 + 13);
const int MAX(LLONG_MAX);
int n, count_bits, hilfe;
bool flag;
string s;
int32_t main() {
boost;
cin >> n;
cin >> s;
for (int i = 0; i < s.size(); i++) {
count_bits += s[i] - '0';
}
if (count_bits < n * 3 || count_bits > n * 6) {
cout << "NIE";
} else {
if (count_bits % 3 == 1) {
cout << "x";
count_bits -= 4;
n--;
} else if (count_bits % 3 == 2) {
cout << "y";
count_bits -=5;
n--;
}
hilfe = count_bits / 3;
while (hilfe > n) {
cout << "w";
hilfe -= 2;
n--;
}
for (int i = 1; i <= n; i++) {
cout << "a";
}
}
cout << endl;
}
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 | #include <bits/stdc++.h> #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define debug(x) cerr << #x << " " << x << endl #define int long long #define st first #define nd second using namespace std; const int N(1e6 + 13); const int MAX(LLONG_MAX); int n, count_bits, hilfe; bool flag; string s; int32_t main() { boost; cin >> n; cin >> s; for (int i = 0; i < s.size(); i++) { count_bits += s[i] - '0'; } if (count_bits < n * 3 || count_bits > n * 6) { cout << "NIE"; } else { if (count_bits % 3 == 1) { cout << "x"; count_bits -= 4; n--; } else if (count_bits % 3 == 2) { cout << "y"; count_bits -=5; n--; } hilfe = count_bits / 3; while (hilfe > n) { cout << "w"; hilfe -= 2; n--; } for (int i = 1; i <= n; i++) { cout << "a"; } } cout << endl; } |
English