Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
117
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. #include <string>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int ans = 0, x = 0;
  9.     std::string s;
  10.     getline(std::cin, s);
  11.     for (uint8_t byte : s) {
  12.         if (x != 0) {
  13.             x--;
  14.         } else {
  15.             ans++;
  16.             for (int i = 7; i >= 0; --i) {
  17.                 if ((byte & (1 << i)) != 0) {
  18.                     x++;
  19.                 } else {
  20.                     break;
  21.                 }
  22.             }
  23.             x = max(0, x - 1);
  24.         }
  25.     }
  26.     cout << ans;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement