#include <iostream> using namespace std; int main() { int n,L = 0; cin>>n; string s; cin>>s; for(int i=0; i<8*n; ++i) { if(s[i] == '1') L++; } if(L < 3*n || L > 6*n) { cout<<"NIE"<<endl; return 0; } int Q,R; Q = L / n; R = L % n; if(Q == 3) { for(int i=0; i<R; ++i) cout<<"c"; for(int i=R; i<n; ++i) cout<<"a"; } else if(Q == 4) { for(int i=0; i<R; ++i) cout<<"z"; for(int i=R; i<n; ++i) cout<<"c"; } else if(Q == 5) { for(int i=0; i<R; ++i) cout<<"w"; for(int i=R; i<n; ++i) cout<<"z"; } else { for(int i=0; i<n; i++) cout<<"w"; } cout<<endl; 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 | #include <iostream> using namespace std; int main() { int n,L = 0; cin>>n; string s; cin>>s; for(int i=0; i<8*n; ++i) { if(s[i] == '1') L++; } if(L < 3*n || L > 6*n) { cout<<"NIE"<<endl; return 0; } int Q,R; Q = L / n; R = L % n; if(Q == 3) { for(int i=0; i<R; ++i) cout<<"c"; for(int i=R; i<n; ++i) cout<<"a"; } else if(Q == 4) { for(int i=0; i<R; ++i) cout<<"z"; for(int i=R; i<n; ++i) cout<<"c"; } else if(Q == 5) { for(int i=0; i<R; ++i) cout<<"w"; for(int i=R; i<n; ++i) cout<<"z"; } else { for(int i=0; i<n; i++) cout<<"w"; } cout<<endl; return 0; } |