#include <bits/stdc++.h> using namespace std; char tab[7]={'0','0','0','a','c','g','o'}; int main(){ // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; string szyfr; cin>>szyfr; int il_1=0; for (int i=0; i<(8*n);i++){ if (szyfr[i]=='1'){ il_1++; } } if (il_1<(3*n) or il_1>(6*n)){ cout<<"NIE"; return 0; } string wynik=""; int mod=il_1%n; int ind=il_1/n; for (int i=0; i<n;i++){ if (mod) { wynik.push_back(tab[ind+1]); mod--; } else wynik.push_back(tab[ind]); } 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 | #include <bits/stdc++.h> using namespace std; char tab[7]={'0','0','0','a','c','g','o'}; int main(){ // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; string szyfr; cin>>szyfr; int il_1=0; for (int i=0; i<(8*n);i++){ if (szyfr[i]=='1'){ il_1++; } } if (il_1<(3*n) or il_1>(6*n)){ cout<<"NIE"; return 0; } string wynik=""; int mod=il_1%n; int ind=il_1/n; for (int i=0; i<n;i++){ if (mod) { wynik.push_back(tab[ind+1]); mod--; } else wynik.push_back(tab[ind]); } cout<<wynik; return 0; } |