mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-25 03:11:41 +08:00
15 lines
158 B
Go
15 lines
158 B
Go
package leetcode
|
|
|
|
func brokenCalc(X int, Y int) int {
|
|
res := 0
|
|
for Y > X {
|
|
res++
|
|
if Y&1 == 1 {
|
|
Y++
|
|
} else {
|
|
Y /= 2
|
|
}
|
|
}
|
|
return res + X - Y
|
|
}
|