#include<bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } void test(int cnt, int a) { while (a > 0) { if (cnt >= a * 6) { cout << "w"; cnt-=6; } else if (cnt >= a * 5) { cout << "n"; cnt-=5; } else if (cnt >= a * 4) { cout << "c"; cnt-=4; } else { cout << "a"; cnt-=3; } a--; } cout << "\n"; } int main() { fastio(); int a; cin >> a; string s; cin >> s; int cnt = count(s.begin(), s.end(), '1'); if (cnt >= a * 3 && cnt <= a * 6) { test(cnt, a); } else { cout << "NIE\n"; } }
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 44 45 46 47 48 49 50 51 52 | #include<bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } void test(int cnt, int a) { while (a > 0) { if (cnt >= a * 6) { cout << "w"; cnt-=6; } else if (cnt >= a * 5) { cout << "n"; cnt-=5; } else if (cnt >= a * 4) { cout << "c"; cnt-=4; } else { cout << "a"; cnt-=3; } a--; } cout << "\n"; } int main() { fastio(); int a; cin >> a; string s; cin >> s; int cnt = count(s.begin(), s.end(), '1'); if (cnt >= a * 3 && cnt <= a * 6) { test(cnt, a); } else { cout << "NIE\n"; } } |