#include <bits/stdc++.h> using namespace std; char T[5] = {' ', 'a', 'c', 'g', 'o'}; int main () { int n, j=0; cin>>n; char c; for (int i=0; i<n*8; ++i) { cin>>c; if (c == '1') j++; } int baza = j/n-2; int k = j%n; if (j>=n*3 && j<=n*6) { for (int i=0; i<k; ++i) cout<<T[baza+1]; for (int i=k; i<n; ++i) cout<<T[baza]; } else cout<<"NIE"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <bits/stdc++.h> using namespace std; char T[5] = {' ', 'a', 'c', 'g', 'o'}; int main () { int n, j=0; cin>>n; char c; for (int i=0; i<n*8; ++i) { cin>>c; if (c == '1') j++; } int baza = j/n-2; int k = j%n; if (j>=n*3 && j<=n*6) { for (int i=0; i<k; ++i) cout<<T[baza+1]; for (int i=k; i<n; ++i) cout<<T[baza]; } else cout<<"NIE"; } |