Divisibility by 64 with removal of bits allowed | CPP program to find if given binary string can become divisible by 64 after removing some bits . ; function to check if it is possible to make it a multiple of 64. ; counter to count 0 's ; length of the string ; loop which traverses right to left and calculates the number of zeros before 1. ; driver code
#include <iostream> NEW_LINE using namespace std ; bool checking ( string s ) { int c = 0 ; int n = s . length ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == '0' ) c ++ ; if ( c >= 6 and s [ i ] == '1' ) return true ; } return false ; } int main ( ) { string s = "100010001" ; if ( checking ( s ) ) cout << " Possible " ; else cout << " Not ▁ possible " ; return 0 ; }