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

相关推荐

不愿透露姓名的神秘牛友
09-30 19:49
起名星人:蛮离谱的,直接要求转投销售
投递汇川技术等公司10个岗位
点赞 评论 收藏
分享
牛客网
牛客企业服务