#include <bits/stdc++.h> #define pb push_back #define ll long long using namespace std; const int MAKS = 5*1e5 + 2; const int MOD = 1e9+7; int tab[MAKS]; int ile[MAKS]; bool CzyByl[MAKS]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string x; cin >> x; int ile_1 = 0; for(int i = 0 ; i < x.size(); i++) { if(x[i] == '1') ile_1 ++; } if(n*3 > ile_1 || ile_1 > n*6) { cout << "NIE"; return 0; } char tab[10]; tab[3] = 'a'; tab[4] = 'c'; tab[5] = 'z'; tab[6] = 'w'; int po_ile = ile_1/n; int tmp = ile_1%n; for(int i = 0 ; i < n ; i++) { if(tmp) { cout << tab[po_ile+1]; tmp--; } else { cout << tab[po_ile]; } } }
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 | #include <bits/stdc++.h> #define pb push_back #define ll long long using namespace std; const int MAKS = 5*1e5 + 2; const int MOD = 1e9+7; int tab[MAKS]; int ile[MAKS]; bool CzyByl[MAKS]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string x; cin >> x; int ile_1 = 0; for(int i = 0 ; i < x.size(); i++) { if(x[i] == '1') ile_1 ++; } if(n*3 > ile_1 || ile_1 > n*6) { cout << "NIE"; return 0; } char tab[10]; tab[3] = 'a'; tab[4] = 'c'; tab[5] = 'z'; tab[6] = 'w'; int po_ile = ile_1/n; int tmp = ile_1%n; for(int i = 0 ; i < n ; i++) { if(tmp) { cout << tab[po_ile+1]; tmp--; } else { cout << tab[po_ile]; } } } |