Walk: you can start your position moves to X + 1 X or X - 1
By bus: you can start your position move to the 2 X X
The time required to walk or take the bus every time is 1 minutes, central south university you want to reach as soon as possible, what is the time required?
Enter
For each set of data, the input line, the N and K (1 & lt;=N, K
=100000)
O
For each set of data, the output of a line, the time needed for
The sample input
5 17
Sample output
4
My code is as follows: when the input sample is larger than 20000 K program will stop the response, what is wrong with==
#include
using namespace std;
Const int maxn=100020;
Int MPT [maxn];
Int vis [maxn];
Int main (void) {
Int m, n;
While (cin> M> N) {
Queue
Memset (MPT, 0, sizeof (MPT));
Memset (vis, 0, sizeof (vis));
for(int i=0; i
Vis [I]=0;
}
while(! Q.e mpty ()) {
Q.p op ();
}
Q.p ush (m);
Vis [m]=1;
int temp;
while(! Q.e mpty ()) {
Int ans=q.f ront ();
Q.p op ();
If (ans==n) {
Cout
}
Temp=ans + 1;
If (vis/temp==0 & amp; & Temp<=100000 & amp; & Temp>=0) {
Vis [\]=1;
MPT [\]=MPT (ans) + 1;
Q.p ush (temp);
}
Temp=ans - 1;
If (vis/temp==0 & amp; & Temp<=100000 & amp; & Temp>=0) {
Vis [\]=1;
MPT [\]=MPT (ans) + 1;
Q.p ush (temp);
}
Temp=ans * 2;
If (vis/temp==0 & amp; & Temp<=100000 & amp; & Temp>=0) {
Vis [\]=1;
MPT [\]=MPT (ans) + 1;
Q.p ush (temp);
}
}
}
return 0;
}