leetcode991】的更多相关文章

On a broken calculator that has a number showing on its display, we can perform two operations: Double: Multiply the number on the display by 2, or; Decrement: Subtract 1 from the number on the display. Initially, the calculator is displaying the num…
class Solution: def brokenCalc(self, X: 'int', Y: 'int') -> 'int': if X>=Y : return Y-X else: num = 0 while Y > X: Z = Y % 2 if Z == 1: num += 1 Y += 1 else:#Z == 0 K = Y // 2 if K >= X: Y = K num += 1 else: num += 1 num += X-K return num retu…