Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 我想知道为什么G++能AC，改用C++却WA了！！！很无语= =

Posted by 541507120156 at 2016-09-27 14:00:28 on Problem 3278
```#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define N 100010
#define INF 2>>30
using namespace std;
int d[N],b[N];
int n,k;
queue<int>q;
int BFS()
{
int i,t,h,flag;
q.push(n);
b[n]=0;
flag=0;
while(!q.empty())
{
h=q.front();
q.pop();
for(i=0;i<3;i++)
{
if(i==0)
t=h-1;
if(i==1)
t=h+1;
if(i==2)
t=h*2;
if(t<0||t>N)
continue;
if(d[t]==INF)
{
d[t]=d[h]+1;
q.push(t);
}
if(t==k)
{
flag=1;
break;
}
}
if(flag)
break;
}
return d[k];
}
int main()
{
while(~scanf("%d%d",&n,&k))
{
fill(d,d+N,INF);
int hh=BFS();
if(n>=k)
printf("%d\n",n-k);
else
printf("%d\n",hh);
}
return 0;
}
```

Followed by:

User ID:
Title:

Content: