Given a string s containing 0's and 1's. You have to return a smallest positive integer C, such that the binary string can be cut into C pieces and each piece should be of the power of 5 with no leading zeros.
Input:
The first line of the input contains T denoting the number of test cases. For each test case, there is a string s.
Output:
For each test case, the output is an integer C. If no such cuts are possible then return -1.
Constraints:
1<=s.length()<=50
Note: The string s is a binary string.
Example:
Input
3
101101101
1111101
00000
Output:
3
1
-1
Explanation:
1.We can split the given string into three “101”s, where 101 is the binary representation of 5.
2."1111101 " is 125 which is 5^3.
3.0 is not a power of 5.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.
mr_kksparrow | 433 |
manvirag982 | 272 |
snow_den_ | 236 |
arpit_anshuman | 228 |
Exception_404 | 220 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |