P11560 广搜狂砍 52 分求调
  • 板块灌水区
  • 楼主封禁用户
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/1/11 21:16
  • 上次更新2025/1/12 10:18:55
查看原帖
P11560 广搜狂砍 52 分求调
1634364
封禁用户楼主2025/1/11 21:16

rt.前情提要

#include<bits/stdc++.h>
using namespace std;
int a,b;
struct node{
	int a,b,step;
};
queue<node> q;
void bfs(){
	q.push({a,b,0});
	while(!q.empty()){
		node f=q.front();
		q.pop();
		if(f.a==f.b){
			cout<<f.step;
			return;
		}
		q.push({f.a*2,f.b,f.step+1});
		q.push({f.a,f.b-1,f.step+1});
		q.push({f.a,f.b+1,f.step+1});
	}
}
int main(){
	cin>>a>>b;
	bfs();
}
2025/1/11 21:16
加载中...