Ball Trajectory Predictor
Statement
Goal
Pong (search the game to help you to visualize) is a game where a ball moves straight (so no gravity) and can be reflected by the top and bottom wall.You need to predict where the ball will hit ON the wall of the first or second player (the verticals walls) to be there before the ball.
Asked Question
there is technically no top/bottom and left/right. As long as you keep your own visualization.
Input
Line 1: an integer W for the width of the screen
Line 2: an integer H for the height of the screen
Line 3: a float r for the direction of the ball (in radian)
Line 4: an integer s for the speed of the ball (the length of the vector)
Line 5: an integer x for the ball starting point
Line 6: an integer y for the ball starting point
Line 2: an integer H for the height of the screen
Line 3: a float r for the direction of the ball (in radian)
Line 4: an integer s for the speed of the ball (the length of the vector)
Line 5: an integer x for the ball starting point
Line 6: an integer y for the ball starting point
Output
Number of whole steps (tip: ceil(distance/speed)) and the y value of the end point position (on a player's wall) (rounded to the nearest integer).
Constraints
50 ≤ W,H
0 ≤ r < 2π
1 ≤ s
0 ≤ x ≤ W
0 ≤ y ≤ H
0 ≤ r < 2π
1 ≤ s
0 ≤ x ≤ W
0 ≤ y ≤ H
Example
Input
400 400 0 1 0 200
Output
400 200
Tags
pong, Trigonometry
Difficulty
Easy
Test cases
straight line Test
Input
400
400
0
1
0
200
Output
400 200
straight line Validator
Input
400
400
0
1
0
300
Output
400 300
diagonal Test
Input
400
400
0.78539816339
1
0
400
Output
566 0
diagonal Validator
Input
400
400
2.35619449019
1
400
400
Output
566 0
boundary Test
Input
800
400
0.78539816339
5
0
100
Output
227 100
boundary Validator
Input
800
200
0.78
1
100
20
Output
985 88
boundary 2 Test
Input
800
800
0.7
1
0
100
Output
1046 774
boundary 2 Validator
Input
700
540
0.24568
3
84
84
Output
212 238
speed Test
Input
10000
400
0.2
100
0
100
Output
103 273
speed Validator
Input
100000
200
0.3
1000
0
100
Output
105 166
light speed Test
Input
1000000
100
0.7
500
0
50
Output
2615 62
true light speed Validator
Input
100000
200
1
1000
0
100
Output
186 159
On the wall Test
Input
50
50
0
100
0
25
Output
1 25
On the wall Validator
Input
100
50
0
200
0
49
Output
1 49
Solution language
Solution
Stub generator input