Advertisement
Guest User

Untitled

a guest
Jul 12th, 2021
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. int find(string s){
  2.     int total = 1, o = 0, z = 1;
  3.     bool flag = 1;
  4.     for(auto i: s){
  5.         if(i == '0'){
  6.             flag = 0;
  7.             int save = total;
  8.             total = 2 * total - z;
  9.             z += save - z;
  10.         }
  11.         else{
  12.             int save = total;
  13.             total = 2 * total - o;
  14.             o += save - o;
  15.         }
  16.     }
  17.     return total - flag;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement