# Baekjoon-13913-숨바꼭질 4

27 Sep 2022```
N,K = map(int, input().split())
queue = [N]
visited = [[-1,[]] for _ in range(int(1e5+1))] # 걸린 시간, 경우의 수
visited[N][0] = 0
visited[N][1].append(N)
while queue:
pos = queue.pop(0)
for i in [pos+1, pos-1, 2*pos]:
if 0 <= i <= int(1e5):
if visited[i][0] == -1:
visited[i][0] = visited[pos][0] + 1
visited[i][1] = pos
queue.append(i)
print(visited[K][0])
# path
path = [K]
while path[-1]!=N:
path.append(visited[path[-1]][1])
path.reverse()
print(*path, sep=' ')
```