← 返回 microsoft 的题目列表Steps to Reduce Binary String to Zero
类型:online_judge
Given a binary string, you can perform two operations on it: If the number is even, divide it by two; if it is odd, subtract one. Determine how many steps it takes to reduce the number to zero.
Input Format:
A single line containing a binary string s representing the input number.
Output Format:
Output an integer representing the number of steps required to reduce the number to zero.
Constraints:
1 ≤ s.length ≤ 100000
Example: Input: 1101 Output: 6
Explanation: The steps are 1101 -> 110 -> 11 -> 10 -> 1 -> 0, totaling 6 steps.
Example
Input
1101