{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eYou 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 \u003ci\u003es\u003c/i\u003e, where you see an elevator. Upon entering the elevator, you learn that it has only two buttons, marked \"UP \u003ci\u003eu\u003c/i\u003e\" and \"DOWN \u003ci\u003ed\u003c/i\u003e\". You conclude that the UP-button takes the elevator \u003ci\u003eu\u003c/i\u003e floors up (if there aren\u0027t enough floors, pressing the UP-button does nothing, or at least so you assume), whereas the DOWN-button takes you \u003ci\u003ed\u003c/i\u003e stories down (or none if there aren\u0027t enough). Knowing that the interview is at floor \u003ci\u003eg\u003c/i\u003e, and that there are only \u003ci\u003ef\u003c/i\u003e 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 \"\u003ctt\u003euse the stairs\u003c/tt\u003e\". \u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nGiven input \u003ci\u003ef\u003c/i\u003e, \u003ci\u003es\u003c/i\u003e, \u003ci\u003eg\u003c/i\u003e, \u003ci\u003eu\u003c/i\u003e and \u003ci\u003ed\u003c/i\u003e (floors, start, goal, up, down), find the shortest sequence of button presses you must press in order to get from \u003ci\u003es\u003c/i\u003e to \u003ci\u003eg\u003c/i\u003e, given a building of floors, or output \"\u003ctt\u003euse the stairs\u003c/tt\u003e\" if you cannot get from \u003ci\u003es\u003c/i\u003e to \u003ci\u003eg\u003c/i\u003e by the given elevator.\r\n\u003c/p\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe input will consist of one line, namely \u003ctt\u003ef s g u d\u003c/tt\u003e, where 1 \u0026lt;\u003d s, g \u0026lt;\u003d f \u0026lt;\u003d 1000000 and 0 \u0026lt;\u003d u, d \u0026lt;\u003d 1000000. The floors are one-indexed, i.e. if there are 10 stories, s and g be in [1; 10].\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eYou must reply with the minimum numbers of pushes you must make in order to get from s to g, or output \"\u003ctt\u003euse the stairs\u003c/tt\u003e\" if it is impossible given the conguration of the elevator.\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10 1 10 2 1\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e100 2 1 1 0 \r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003euse the stairs\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}