def GetMinCalculateCount(self, sourceX, sourceY, targetX, targetY) : # write code here if sourceX>targetX or sourceY > targetY: return -1 if sourceX==targetX and sourceY != targetY: return -1 if sourceX != targetX and sourceY == targetY: return -1 count = 0 while 2*sourceX<=targetX and 2*sourceY<=targetY and targetX-1>0 and targetY-1>0: if targetX%2==0 and targetY%2 == 0: targetX /= 2 targetY /= 2 count += 1 else: targetX -= 1 targetY -= 1 count += 1 if targetX - sourceX != targetY - sourceY: return -1 count += targetX-sourceX return count 要py2才能100, py3是50, 差点被坑了
1 2

相关推荐

不愿透露姓名的神秘牛友
12-16 15:57
小鹏汽车 java后端 22*15(固定13,2个月年终) 硕士211
点赞 评论 收藏
分享
11-20 15:03
四川大学 Java
点赞 评论 收藏
分享
11-04 10:30
已编辑
门头沟学院 研发工程师
开心小狗🐶:“直接说答案”
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务