//µ÷ÓÃqueue¿â
#include <iostream>
#include <queue>
using namespace std;
int main(int argc, char* argv[])
{
int N, K;
cin >> N >> K;
const int MAXSIZE = 200002;
int line[MAXSIZE];
memset(line, -1, sizeof(line));
queue<int> q;
q.push(N);
line[N] = 0;
while(!q.empty())
{
int stp = q.front();
q.pop();
int next = stp - 1;
if (next >= 0 && line[next] == -1)
{
line[next] = line[stp] + 1;
q.push(next);
if (next==K)
break;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载