#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, suma=0; string x, odp=" acgw "; cin >> n; cin >> x; for(int i= 0; i<x.length(); i++) { suma = suma + (x[i] - '0'); } if (suma >= 3 * n and suma <= 6 * n) { int superzmienna = suma % n; suma /= n; cout << odp[suma + superzmienna]; n--; while (n--) { cout << odp[suma]; } } else cout << "NIE"; 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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, suma=0; string x, odp=" acgw "; cin >> n; cin >> x; for(int i= 0; i<x.length(); i++) { suma = suma + (x[i] - '0'); } if (suma >= 3 * n and suma <= 6 * n) { int superzmienna = suma % n; suma /= n; cout << odp[suma + superzmienna]; n--; while (n--) { cout << odp[suma]; } } else cout << "NIE"; return 0; } |