Advertisement
_takumi

num12

Nov 23rd, 2020 (edited)
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main() {
  9.     string s(1, '1');
  10.     string s1(80, '0');
  11.     s.append(s1);
  12.     while (s.find("10") != string::npos || s.find("1") != string::npos) {
  13.         if (s.find("10") != string::npos) {
  14.             s.replace(s.find("10"), 2, "001");
  15.         }
  16.         else if (s.find("1") != string::npos)
  17.         {
  18.             s.replace(s.find("1"), 1, "000");
  19.         }
  20.     }
  21.     cout << count(begin(s), end(s), '0');
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement