用bfs可以,个人觉得dfs应该很麻烦!觉得用最短路径更好理解,也容易实现,对点做预处理,用队列把有关点之间的权值设置成1,这样再用最短路径求解
Problem Description
There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will
go up Ki floor,i.e,you will go to the i+Ki th floor,as the same, if you press the button "DOWN" ......
阅读全文