```cpp
#include<bits/stdc++.h>
using namespace std;
int ans=0,n,m,a[100001];
struct node
{
int x,step;
node(int xx,int dep)
{
x=xx;
step=dep;
}
node()
{
}
};
queue<node> q;
void bfs(int s)
{
q.push(node(s,0));
while(!q.empty())
{
node now=q.front();
q.pop();
if(now.step==m)
{
if(now.x==1)
{
ans++;
}
continue;
}
if(now.x+1<=n&&now.x-1>=1)
{
q.push(node(now.x+1,now.step+1));
q.push(node(now.x-1,now.step+1));
}
else if(now.x+1<=n&&now.x-1<1)
{
q.push(node(now.x+1,now.step+1));
q.push(node(n,now.step+1));
}
else if(now.x+1>n&&now.x-1>=1)
{
q.push(node(1,now.step+1));
q.push(node(now.x-1,now.step+1));
}
else
{
q.push(node(1,now.step+1));
q.push(node(n,now.step+1));
}
}
}
int main()
{
scanf("%d %d",&n,&m);
bfs(1);
printf("%d\n",ans);
}
```
by 西方不buy菌 @ 2020-12-14 20:10:33
这题不难,方法错怪谁
by rui_er @ 2020-12-14 20:14:23
这不是傻逼题吗,建议降橙
by AsunderSquall @ 2020-12-14 20:14:34
这不是sbdp?
by monstersqwq @ 2020-12-14 20:16:52
~~降橙没面子了,降红吧!!~~
by 西方不buy菌 @ 2020-12-14 20:17:02
这题用动规做,搜索不是正解
by FutureThx @ 2020-12-14 20:19:48
您好像就是口出:
>洛谷是个学术网站?
的神犇吧?
这不是SB题吗?
by lmrttx @ 2020-12-14 20:22:02
这题代码不是不压行都只有14行的吗
by 血色黄昏 @ 2020-12-14 20:23:02
[来考lz的古啊(](https://www.luogu.com.cn/blog/254389/xi-fang-fou-buy-jun-yu-lu)
by _短笛无腔_ @ 2020-12-14 20:23:30
你谷新一代最著名xxs,没有之一
by Stinger @ 2020-12-14 20:28:59