x = int(input()) n = 0 def getstep(x, step): step += 1 if x == 1: res.append(step) step -= 1 elif x < 0: step -= 1 getstep(-x, step) else: if x % 2 == 0: getstep(x / 2, step) else: getstep(x - 1, step) getstep(x + 1, step) step = 0 res = [] if x == 0: print(step) else: step = getstep(x, step) print(min(res))
递归
不允许题解没有python