Company: Salesforce_12nov
Difficulty: medium
Salesforce data processing system Problem Description A server starts at energy level n . In one operation the system may do exactly one of the following: Increase the energy level by 2^i , for any integer i >= 0 . Decrease the energy level by 2^i , for any integer i >= 0 . Determine the minimum number of operations needed to bring the energy level down to 0 . Complete the function getSystemOperations . It takes the starting energy level n and returns the minimum number of operations. Input Format A single line containing one integer n . Output Format Print a single integer: the minimum number of operations required to reduce n to 0 . Constraints 1 <= n < 2^60 Note that n does not fit in a 32-bit signed integer, so a 64-bit type is required in C++ and Java. Examples Example 1 Input: 5 Output: 2 Explanation: choose i = 0 and subtract 2^0 = 1 from 5 to get 4 , then choose i = 2 and subtract 2^2 = 4 from 4 to get 0 . It can be shown that the answer cannot be less than 2 . Exam