力扣第991题 坏了的计算器

力扣第991题 坏了的计算器

class Solution {
    public:
    int brokenCalc(int X, int Y) {
        int res = 0;
        while (Y > X)
        {
            res++;
            if ((Y & 1))
            {
                Y++;
            }
            else
            {
                Y >>= 1;
            }
        }
        return res + X - Y;
    }
};
原文地址:https://www.cnblogs.com/woodjay/p/12417044.html