#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, t = 0; string s, r; cin >> n >> s; for(auto& a: s) t += a - '0'; if (n * 3 <= t && n * 6 >= t) { while (n) { cout << "peso"[t / n - 3]; t -= t / n--; } } else cout << "NIE"; 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 | #include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, t = 0; string s, r; cin >> n >> s; for(auto& a: s) t += a - '0'; if (n * 3 <= t && n * 6 >= t) { while (n) { cout << "peso"[t / n - 3]; t -= t / n--; } } else cout << "NIE"; cout << "\n"; return 0; } |