#d2147. BFS练习1
BFS练习1
BFS Practice 1
Problem Description
You are given a number . Each step you may choose one of the following four operations:
- Add one to .
- Multiply by .
- Multiply by .
- Subtract one from .
Find the minimum number of steps to change into .
You need to answer queries, with targets ; output the minimum number of steps to change into .
Input Format
The first line contains two integers .
The next line contains integers .
Output Format
Output numbers, the minimum number of steps to change into respectively.
Sample Input
3 10
1 2 3 4 5 6 7 8 9 10
Sample Output
2 1 0 1 2 1 2 2 1 2
Constraints
For all data, .