#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); int n;cin>>n; int Q=0; for(int i=0;i<8*n;i++){ char y;cin>>y; if(y=='1')Q++; } if(Q<3*n or Q>6*n){ cout<<"NIE";return 0; } n++; while(--n){ if(Q>5*n){ cout<<"w";Q-=6; } else if(Q>4*n){ cout<<"v";Q-=5; } else if(Q>3*n){ cout<<"c";Q-=4; } else{ cout<<"a";Q-=3; } } 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 | #include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); int n;cin>>n; int Q=0; for(int i=0;i<8*n;i++){ char y;cin>>y; if(y=='1')Q++; } if(Q<3*n or Q>6*n){ cout<<"NIE";return 0; } n++; while(--n){ if(Q>5*n){ cout<<"w";Q-=6; } else if(Q>4*n){ cout<<"v";Q-=5; } else if(Q>3*n){ cout<<"c";Q-=4; } else{ cout<<"a";Q-=3; } } return 0; } |