#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <unordered_set> #include <queue> using namespace std; int main(){ int n = 0; cin >> n; int sum = 0; string s; cin >> s; for(int i = 0; i < 8*n; ++i){ //cout << ((int)s[i]) << " "; sum += ((int)s[i]) - 48; } //cout << sum << "\n"; string liter = "+++acgo"; if( (sum < (3*n)) || (sum > (6*n)) ){ cout << "NIE" << "\n"; } else { int k = sum/n; int q = sum%n; for(int i=q; i<n; ++i){ cout << liter[k]; } for(int i=0; i<q; ++i){ cout << liter[k+1]; } cout << "\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 | #include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <unordered_set> #include <queue> using namespace std; int main(){ int n = 0; cin >> n; int sum = 0; string s; cin >> s; for(int i = 0; i < 8*n; ++i){ //cout << ((int)s[i]) << " "; sum += ((int)s[i]) - 48; } //cout << sum << "\n"; string liter = "+++acgo"; if( (sum < (3*n)) || (sum > (6*n)) ){ cout << "NIE" << "\n"; } else { int k = sum/n; int q = sum%n; for(int i=q; i<n; ++i){ cout << liter[k]; } for(int i=0; i<q; ++i){ cout << liter[k+1]; } cout << "\n"; } return 0; } |