Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int sum = 0, notX, isX, subNotX, subIsX, h;
  6. string s;
  7.  
  8. int its(string s) {
  9.     int result = 0;
  10.     for (int i = 0 ; i < s.length() ; i++)
  11.         result = result * 10 + s[i] - 48;
  12.     return result;
  13. }
  14.  
  15. int main()
  16. {
  17.     cin >> h;
  18.     for (int i = 0 ; i < h ; i++) {
  19.         cin >> s;
  20.         if (s == "x") {
  21.             notX   += subNotX;
  22.             isX    += subIsX + 1;
  23.             subIsX += 1;
  24.         } else {
  25.             notX    += subNotX + its(s);
  26.             isX     += subIsX;
  27.             subNotX += its(s);
  28.         }
  29.         cout << isX << endl;
  30.     }
  31.  
  32.     cout << notX << " + " << isX;
  33. }
Add Comment
Please, Sign In to add comment