#include <iostream> using namespace std; char tab[4] = {'a', 'c', 'g', 'o'}; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int ones = 0, n; string x; cin >> n >> x; for(int i = 0; i < x.size(); i++) ones += x[i] == '1'; int maxnumones = ones/n; if(maxnumones < 3 or maxnumones > 6 or (maxnumones == 6 and maxnumones*n < ones)){ cout << "NIE\n"; return 0; } int rest = ones - maxnumones*n; for(int i = 0; i < n; i++) if(i < rest) cout << tab[maxnumones - 2]; else cout << tab[maxnumones - 3]; 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 | #include <iostream> using namespace std; char tab[4] = {'a', 'c', 'g', 'o'}; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int ones = 0, n; string x; cin >> n >> x; for(int i = 0; i < x.size(); i++) ones += x[i] == '1'; int maxnumones = ones/n; if(maxnumones < 3 or maxnumones > 6 or (maxnumones == 6 and maxnumones*n < ones)){ cout << "NIE\n"; return 0; } int rest = ones - maxnumones*n; for(int i = 0; i < n; i++) if(i < rest) cout << tab[maxnumones - 2]; else cout << tab[maxnumones - 3]; cout << endl; return 0; } |