#include <bits/stdc++.h> #include<algorithm> #include <math.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pi; const ll maxn = 2e5 + 100; const ll inf = 1e9; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define pb push_back #define pii pair<int, pair<int, int>> #define mp make_pair #define f first #define s second #define all(x) (x).begin(), (x).end() int main() { fast_io; string ans; int n; cin >> n; vector <int> l; int cnt = 0; for (int i = 0; i < 8*n; i ++) { char x; cin >> x; if (x == '1') { cnt += 1; } l.pb(x); } int per = cnt / n; int mod = cnt % n; bool answer = true; if (per == 3) { for (int i = 0; i < n - mod; i++) { ans.pb('a'); } for (int i = 0; i < mod; i++) { ans.pb('c'); } } else if (per == 4) { for (int i = 0; i < n - mod; i++) { ans.pb('c'); } for (int i = 0; i < mod; i++) { ans.pb('g'); } } else if (per == 5) { for (int i = 0; i < n - mod; i++) { ans.pb('g'); } for (int i = 0; i < mod; i++) { ans.pb('o'); } } else if (per == 3) { if (mod == 0) { for (int i = 0; i < n - mod; i++) { ans.pb('o'); } } else { answer = false; cout << "NIE"; } } else { cout << "NIE"; } if (answer) { cout << ans; } }
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <bits/stdc++.h> #include<algorithm> #include <math.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pi; const ll maxn = 2e5 + 100; const ll inf = 1e9; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define pb push_back #define pii pair<int, pair<int, int>> #define mp make_pair #define f first #define s second #define all(x) (x).begin(), (x).end() int main() { fast_io; string ans; int n; cin >> n; vector <int> l; int cnt = 0; for (int i = 0; i < 8*n; i ++) { char x; cin >> x; if (x == '1') { cnt += 1; } l.pb(x); } int per = cnt / n; int mod = cnt % n; bool answer = true; if (per == 3) { for (int i = 0; i < n - mod; i++) { ans.pb('a'); } for (int i = 0; i < mod; i++) { ans.pb('c'); } } else if (per == 4) { for (int i = 0; i < n - mod; i++) { ans.pb('c'); } for (int i = 0; i < mod; i++) { ans.pb('g'); } } else if (per == 5) { for (int i = 0; i < n - mod; i++) { ans.pb('g'); } for (int i = 0; i < mod; i++) { ans.pb('o'); } } else if (per == 3) { if (mod == 0) { for (int i = 0; i < n - mod; i++) { ans.pb('o'); } } else { answer = false; cout << "NIE"; } } else { cout << "NIE"; } if (answer) { cout << ans; } } |