CCC '10 J2 - Up and Down

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Canadian Computing Competition: 2010 Stage 1, Junior #2

Nikky and Byron are playing a silly game in gym class.

Nikky is told by his teacher to walk forward a steps (1 \le a \le 100) and then walk backward b steps (1 \le b \le 100), after which he repeats a forward, b backward, etc. Likewise, Byron is told to walk forward c steps (1 \le c \le 100) and then walk backward d steps (1 \le d \le 100), after which he repeats c forward, d backward, etc. You may assume that a \ge b and c \ge d.

Byron and Nikky have the same length of step, and they are required to take their steps simultaneously (that is, Nikky and Byron will both step forward on their first steps at the same time, and this will continue for each step).

Nikky and Byron start walking from one end of a soccer field. After s steps (1 \le s \le 10\,000), the gym teacher will blow the whistle. Your task is to figure out who has moved the farthest away from the starting position when the whistle is blown.

Input Specification

The input will be the 5 integers a, b, c, d, and s, each on a separate line.

Output Specification

The output of your program will be one of three possibilities: Nikky if Nikky is farther ahead after s steps are taken; Byron if Byron is farther ahead after s steps are taken; Tied if Byron and Nikky are at the same distance from their starting position after s steps are taken.

Sample Input

4
2
5
3
12

Output for Sample Input

Byron

Explanation of Output for Sample Input

Notice that after 12 steps, Nikky has moved 4-2+4-2 steps, for a total of 4 steps from the starting position, whereas Byron has moved 5-3+4 steps, for a total of 6 steps from the starting position. Thus, Byron is ahead.


Comments


  • 1
    0Power10  commented on July 20, 2021, 3:45 p.m.

    I spent so long thinking they do their forward and back one time maximum then i realized they loop it until the whistle blows


  • 1
    sdesai9192  commented on July 20, 2021, 2:55 p.m.

    Why doesn't my test case #4 work?


    • 4
      Badmode  commented on July 20, 2021, 5:07 p.m. edited

      Try this testcase (also for others failing testcase #4):

      10
      0
      20
      0
      5

      Output should be Tied, not Byron.


      • 1
        sdesai9192  commented on July 21, 2021, 7:28 a.m.

        Oh, I think I know what I was doing wrong- thanks!


  • 1
    iiGam_r  commented on Feb. 16, 2021, 7:44 p.m.

    It seems that the common problem I am having, is test case 1 and test case 4. If there is anyone else with the same problem as me, and in anyway cases, please help me and other people.


  • -4
    wome  commented on Oct. 16, 2020, 5:04 a.m.

    what I need to print when Nikky and Byron is same


  • -4
    liuhans731  commented on March 21, 2020, 9:53 a.m.

    I have got IR can someone tells me what that means and how to fix it.


  • -1
    Woofless77  commented on Feb. 27, 2019, 8:55 p.m. edited

    Is it just me or has anyone else experienced all the outputs for Byron fail.

    Never mind. Just needed to make sure it was the absolute value.


  • 18
    institutionalisation  commented on July 23, 2018, 8:10 a.m.

    Spent half an hour spelling Byron as Bryon and Nikky as Nicky.


  • -6
    loltrollkill  commented on Feb. 7, 2018, 6:24 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 4
      KevinLu  commented on Feb. 16, 2018, 6:36 p.m.

      Tied if Byron and Nikky are at the same distance from their starting position after s steps are taken.


      • 1
        DotonPY  commented on Oct. 9, 2020, 8:44 p.m.

        That means it outputs 'Tied'.


  • -56
    Yuting9  commented on April 15, 2015, 9:14 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 7
      quantum  commented on April 15, 2015, 9:19 a.m.

      How do you know what the test case should be? Think first whether it would be arrogant to suggest all the people who got AC are wrong.


      • 56
        Yuting9  commented on April 17, 2015, 10:42 a.m.

        I had read the question statement wrong. I apologize for my previous comment.