Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sum = 0, notX, isX, subNotX, subIsX, h;
- string s;
- int its(string s) {
- int result = 0;
- for (int i = 0 ; i < s.length() ; i++)
- result = result * 10 + s[i] - 48;
- return result;
- }
- int main()
- {
- cin >> h;
- for (int i = 0 ; i < h ; i++) {
- cin >> s;
- if (s == "x") {
- notX += subNotX;
- isX += subIsX + 1;
- subIsX += 1;
- } else {
- notX += subNotX + its(s);
- isX += subIsX;
- subNotX += its(s);
- }
- cout << isX << endl;
- }
- cout << notX << " + " << isX;
- }
Add Comment
Please, Sign In to add comment