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

相关推荐

05-07 17:58
门头沟学院 Java
wuwuwuoow:1.简历字体有些怪怪的,用啥写的? 2.Redis 一主二从为什么能解决双写一致性? 3.乐观锁指的是 SQL 层面的库存判断?比如 stock > 0。个人认为这种不算乐观锁,更像是乐观锁的思想,写 SQL 避免不了悲观锁的 4.奖项证书如果不是 ACM,说实话没什么必要写 5.逻辑过期时间为什么能解决缓存击穿问题?逻辑过期指的是什么 其实也没什么多大要改的。海投吧
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客网
牛客企业服务