常德红网官网网站,网站建设汇报会,重庆互联网公司排行榜,化妆品 网站建设案例题目#xff1a; 题解#xff1a;
class Solution:def integerReplacement(self, n: int) - int:ans 0while n ! 1:if n % 2 0:ans 1n // 2elif n % 4 1:ans 2n // 2else:if n 3:ans 2n 1else:ans 2n n // 2 1return ans题目 题解
class Solution:def integerReplacement(self, n: int) - int:ans 0while n ! 1:if n % 2 0:ans 1n // 2elif n % 4 1:ans 2n // 2else:if n 3:ans 2n 1else:ans 2n n // 2 1return ans