UVa 11130

It says there is a billiard table and from the center of it we hit a ball. Table has no holes. eventually, for friction velocity of ball goes down and finally comes in rest. We have to calculate how many times the ball hit to the vertical and horizontal walls. Angle in which the ball is shot is given and it is measured anticlockwise direction from the horizon.

Explanation
Instead of reflecting the ball multiple times after each hit, we can let it go in straight line and see how many times the line cuts vertical and horizontal walls of the table. https://algorithmist.com/wiki/File:Billiard_ball.jpg#filehistory see the picture for more clarity.

Gotchas
Calculate the distance covered by the ball. As the velocity not uniform distance covered would come (v*t)/2. Format of the angle given in question in degree, So covert it to radian.

Implementations
distance along x axis= ((v*t)/2)*cos(theta) distance along y axis= ((v*t)/2)*sin(theta) Let theta be the angle of first shot. so, no. of hits in vertical axis=ceil((distance_x/(length of horizontal border/2))/2) no. of hits in horizontal axis=ceil((distance_y/(length of vertical border/2))/2)

Optimizations
Optimizations here.

Input
100 50 10 90 10 100 50 10 0 40 88 33 7 48 19 0 0 0 0 0 0

Output
0 1 2 0 1 0