Up and Down
InterviewTime limit2sMemory limit512 MB
Two walkers repeat a forward/backward step cycle; after s steps, report whose distance from the start is greater, or Tied.
- Level
Easy3 of 10
- Topics
- Simulation, Math, Implementation, Array
- Solved
- No attempts yet
Problem
Nikky and Byron are playing a simple game in gym class.
Nikky's teacher tells him to walk forward steps () and then backward steps (), and to keep repeating this pattern: forward, backward, forward, backward, and so on. Byron is told to walk forward steps () and then backward steps (), repeating forward, backward, and so on. You may assume that and .
Nikky and Byron have the same step length, and they take every step at the same time (both take their first step forward simultaneously, and each step after that is simultaneous as well).
Both start from one end of a soccer field. After a total of steps (), the gym teacher blows the whistle. Determine who is farther from the starting position at that moment.
Input
Five integers , , , , and , each on its own line.
Output
Print exactly one of the following:
Nikkyif Nikky is farther from the start after steps,Byronif Byron is farther from the start,Tiedif both are the same distance from the start.