#include <bits/stdc++.h> using namespace std; #define true rand()%2 #define ll long long #define p_b push_back #define m_p make_pair #define fi first #define se second ll inf = 1000000007; ll mod = 1000000007; const int maxn = 1048579; char c[7]; int main(){ ios_base::sync_with_stdio(0); int n; cin>>n; int np = n*8; string s; cin>>s; int lz = 0; for(auto i: s) if(i=='1') lz++; int mi = lz/n, ma = lz/n; if(lz%n) ma++; c[3] = 'a'; c[4] = 'c'; c[5] = 'g'; c[6] = 'o'; if(3<=mi && ma<=6){ int ima = lz%n; for(int i = 0; i<ima; i++) cout<<c[ma]; for(int i = ima; i<n; i++) cout<<c[mi]; } 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <bits/stdc++.h> using namespace std; #define true rand()%2 #define ll long long #define p_b push_back #define m_p make_pair #define fi first #define se second ll inf = 1000000007; ll mod = 1000000007; const int maxn = 1048579; char c[7]; int main(){ ios_base::sync_with_stdio(0); int n; cin>>n; int np = n*8; string s; cin>>s; int lz = 0; for(auto i: s) if(i=='1') lz++; int mi = lz/n, ma = lz/n; if(lz%n) ma++; c[3] = 'a'; c[4] = 'c'; c[5] = 'g'; c[6] = 'o'; if(3<=mi && ma<=6){ int ima = lz%n; for(int i = 0; i<ima; i++) cout<<c[ma]; for(int i = ima; i<n; i++) cout<<c[mi]; } else cout<<"NIE"; } |