Advertisement
Alexvans

Untitled

Sep 5th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.    ios_base::sync_with_stdio(0);
  6.    cin.tie(0);
  7.    cout.tie(0);
  8.    string cad;
  9.    cin >> cad;
  10.  
  11.    int p = 0, f = 0;
  12.  
  13.    for(int i = 0; i < cad.size(); ) {
  14.       if((cad[i]-'0') == 1) {
  15.          p++;
  16.          i += 4;
  17.       }
  18.       else {
  19.          p++;
  20.          i+=3;
  21.       }
  22.    }
  23.    for(int i = cad.size()-1; i >=0; ) {
  24.       if((cad[i-4]-'0') == 1) {
  25.          f++;
  26.          i -= 4;
  27.       }
  28.       else {
  29.          f++;
  30.          i-=3;
  31.       }
  32.    }
  33.    cout << p << " " << f;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement