Advertisement
_takumi

num12

Oct 26th, 2020
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main() {
  8.     string s(99, '1');
  9.     cin >> s;
  10.     while (s.find("111") != string::npos) {
  11.         s.replace(s.find("111"), 3, "22");
  12.         if (s.find("222") != string::npos) {
  13.             s.replace(s.find("222"), 3, "11");
  14.         }
  15.     }
  16.     cout << s;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement