1 class Solution:
 2     def brokenCalc(self, X: 'int', Y: 'int') -> 'int':
 3         if X>=Y :
 4             return Y-X
 5         else:
 6             num = 0
 7             while Y > X:
 8                 Z = Y % 2
 9                 if Z == 1:
10                     num += 1
11                     Y += 1
12                 else:#Z == 0
13                     K = Y // 2
14                     if K >= X:
15                         Y = K
16                         num += 1
17                     else:
18                         num += 1
19                         num += X-K
20                         return num
21         return num

 

posted on 2019-02-11 16:26  Sempron2800+  阅读(165)  评论(0编辑  收藏  举报