spoj Elevator Trouble
来源:互联网 发布:5g网络支持两张电信卡 编辑:程序博客网 时间:2024/06/06 14:06
ELEVTRBL - Elevator Trouble
You are on your way to your first job interview as a program tester, and you are already late. The interview is in a skyscraper and you are currently in floor s, where you see an elevator. Upon entering the elvator, you learn that it has only two buttons, marked "UP u" and "DOWN d". You conclude that the UP-button takes the elevator u floors up (if there aren't enough floors, pressing the UP-botton does nothing, or at least so you assume), whereas the DOWN-button takes you d stories down (or none if there aren't enough). Knowing that the interview is at floor g, and that there are only f floors in the building, you quickly decide to write a program that gives you the amount of button pushes you need to perform. If you simply cannot reach the correct floor, your program halts with the message "use the stairs".
Given input f, s, g, u and d (floors, start, goal, up, down), fi nd the shortest sequence of button presses you must press in order to get from s to g, given a building of floors, or output "use the stairs" if you cannot get from s to g by the given elevator.
Input
The input will consist of one line, namely f s g u d, where 1 <= s, g <= f <= 1000000 and 0 <= u, d <= 1000000. The floors are one-indexed, i.e. if there are 10 stories, s and g be in [1; 10].
Output
You must reply with the minimum numbers of pushes you must make in order to get from s to g, or output "use the stairs" if it is impossible given the con guration of the elevator.
Example
Input:10 1 10 2 1Output:6
Input:100 2 1 1 0 Output:use the stairs
- spoj Elevator Trouble
- Elevator Trouble
- Elevator Trouble解题报告
- BNU 25588 Elevator Trouble【裸BFS】
- hrbust 哈理工OJ 1498Elevator Trouble【BFS过】
- trouble
- trouble
- Elevator
- Elevator
- Elevator
- elevator
- Elevator
- Elevator
- Elevator
- Elevator
- Elevator
- elevator
- Elevator
- iOS开发笔记之设置view部分圆角
- 实践中的前后端分离
- 常用JS正则表达式
- ASP.NET.MVC学习(1)
- win10触摸板双击没反应
- spoj Elevator Trouble
- Android Material Design TabLayout属性app:tabMode和app: tabGravity
- BZOJ1597 [Usaco2008 Mar]土地购买
- ORA-600 [kghstack_free2] Raised by Corrupt Datafile (文档 ID 748310.1)
- Altium Designer 原理图检查总结
- HDU 5410 CRB and His Birthday 混合背包(01背包和完全背包混合)
- 关于Tomcat端口被占用的问题
- ActiveMQ小记(一):监控
- cookie简单理解