Given a binary string, we need to check whether that number is divisible by 64 or not after removing of some bits. If yes then print “possible” else “not possible”. We cannot make number 0 to make it divisible.
Input: 100010001 Output: Possible Explanation: We can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system. Input: 100 Output: Not possible Explanation : The number is 4 which is not divisible by 64 or cannot be made possible my removing some digits.
If we have 6 zeros after any one, then we can remove other bits represent it as a multiple of 64. So we just need to check if there is a 1 before six zeros.
Time Complexity: O(length of string)
This article is contributed by Twinkle Bajaj. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Game of Nim with removal of one stone allowed
- Check divisibility by 7
- Sub-string Divisibility by 3 Queries
- Sub-string Divisibility by 11 Queries
- Maximum path sum for each position with jumps under divisibility condition
- Check divisibility in a binary stream
- To check divisibility of any large number by 999
- Check if a large number is divisibility by 15
- Divisibility by 12 for a large number
- Repeated Unit Divisibility
- Check divisibility of binary string by 2^k
- Maximize profit when divisibility by two numbers have associated profits
- Check if bits of a number has count of consecutive set bits in increasing order
- Toggle bits of a number except first and last bits
- Print numbers having first and last bits as the only set bits
- Check if all bits can be made same by flipping two consecutive bits
- Find position of given term in a series formed with only digits 4 and 7 allowed
- Write an Efficient C Program to Reverse Bits of a Number
- Count set bits in an integer
- Count number of bits to be flipped to convert A to B