#include <bits/stdc++.h> using namespace std; bool pos(int a, int b){ //if(b<=0) return false; int mini = 3*b; int maxi = 6*b; if(a>=mini&&a<=maxi) return true; return false; } int main(){ ios_base::sync_with_stdio(0); int n; cin>>n; int a = 0; for(int i = 0; i < n*8; i++){ char c; cin>>c; if(c=='1') a++; } if(pos(a, n)){ while(pos(a-6, n-1)){ cout<<'o'; a-=6; n-=1; } while(pos(a-5, n-1)){ cout<<'n'; a-=5; n-=1; } while(pos(a-4, n-1)){ cout<<'c'; a-=4; n-=1; } while(pos(a-3, n-1)){ cout<<'a'; a-=3; n-=1; } cout<<'\n'; }else{ cout<<"NIE\n"; } 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 40 41 42 43 | #include <bits/stdc++.h> using namespace std; bool pos(int a, int b){ //if(b<=0) return false; int mini = 3*b; int maxi = 6*b; if(a>=mini&&a<=maxi) return true; return false; } int main(){ ios_base::sync_with_stdio(0); int n; cin>>n; int a = 0; for(int i = 0; i < n*8; i++){ char c; cin>>c; if(c=='1') a++; } if(pos(a, n)){ while(pos(a-6, n-1)){ cout<<'o'; a-=6; n-=1; } while(pos(a-5, n-1)){ cout<<'n'; a-=5; n-=1; } while(pos(a-4, n-1)){ cout<<'c'; a-=4; n-=1; } while(pos(a-3, n-1)){ cout<<'a'; a-=3; n-=1; } cout<<'\n'; }else{ cout<<"NIE\n"; } return 0; } |