Minimum Operations to Make the Integer Zero
You are given two integers num1 and num2.
In one operation, you can choose an integer i in the range [0, 60] and subtract 2^i + num2 from num1.
Return the integer denoting the minimum number of operations needed to make num1 equal to 0.
If it is impossible to make num1 equal to 0, return -1.
Example 1
Input
num1 = 3, num2 = -2Output
3We can make 3 equal to 0 in 3 operations, and it can be proven that 3 is the minimum number needed.
Example 2
Input
num1 = 5, num2 = 7Output
-1It can be proven that it is impossible to make 5 equal to 0 with the given operation.
Constraints
- 1 <= num1 <= 10^9
- -10^9 <= num2 <= 10^9