DWITE '08 R4 #1 - Four player Pong with no players

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Problem type
DWITE Online Computer Programming Contest, January 2008, Problem 1

This "game" has been simplified so much that all the players left. Incidentally, with no paddles left on the screen, it makes it even more simple, as there is nothing to bounce off. The only objective left now is to figure out where the ball will hit the edge of the playfield.

The playfield is a rectangle of the size 100 wide by 50 high. Lower left corner is at (0,0); upper right is at (100,50). The ball is the size of a single pixel, and the score counts as that pixel lands on the edge. The ball starts at the center, at (50,25), and its velocity will be provided in the input.

The input will contain 5 sets of input, 2 lines each. The first line will be an integer value -10 \le H \le 10, the horizontal component of the velocity. The second line will be an integer value -10 \le V \le 10, the vertical component of the velocity. There will be no 0,0 input, and thus there will always be a solution.

The output will contain 5 lines, the location where the ball hits the edge, in the x, y format.

Note: if one was to simulate the game using a loop, the integer values in all of the cases will land exactly on an edge during one of the steps.

Another note: Some might want to draw to screen while developing or debugging their code – this could be helpful to get a better idea of what's going on, but please remember to comment out any graphical code before submitting a solution.

Sample Input

5
0
0
-5
5
5

Sample Output

100,25
50,0
75,50

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments


  • 3
    jorispos  commented on Feb. 20, 2019, 9:03 p.m.

    Why does the Sample input and output not match the explanation of the in and output at the top part of the document? Or am i missing something.

    Ex:

    output will contain 5 lines, the location where the ball hits the edge, in the x,y format.

    and then the sample output only has 3 lines

    100,25
    50,0
    75,50

    Same problem with the sample input.


    • 1
      p1geon  commented on Feb. 21, 2019, 12:49 a.m.

      The samples only have 3 cases; the actual test case has 5.