Home > Back-end >  Why turn POJ3278 WA
Why turn POJ3278 WA

Time:11-27

Trouble help have a look, great god,




#include
#include
#include
using namespace std;
__int64 a [100010], n, k;
Int I, j;
Struct node {
__int64 x;
Int s;//record location x, s record count
};

Int BFS ()
{
The node m, next;
Queue Q;
M.x=n;
Margaret spellings=0;
A [n]=1;
Q.p ush (m);//into the stack
while(! Q.e mpty ())
{
M=q.f ront ();
Q.p op ();
for(i=0; i<3; I++)
{
If (I==0)
{
Next, x=m.x * 2;
Next, s=Margaret spellings + 1;
}
If (I==1)
{
Next. X=m.x + 1;
Next, s=Margaret spellings + 1;
}
If (I==2)
{
Next, x=m.x - 1;
Next, s=Margaret spellings + 1;
}
If (next. X<0 | | next. X> K)
continue;
If (a [next] x!
=1){
If (next. X==k)
Return next. S;
Q.p ush (next);
A [next] x=1;
}
}
}
}

Int main ()
{
While (the scanf (" % I64d % I64d ", & amp; N, & amp; k)!=(EOF)
{memset (a, 0, sizeof (a));
Int sum;
Sum=BFS ();
If (n>=k) printf (" % I64d \ n, n - k);
The else coutreturn 0;
}
  • Related