The problem states that, a billiard table of size S*S and a billiard ball at point (x1,y1) is given. There is another point given at (x2,y2) and when we shoot the ball it goes through the second point. So what is minimum number of times the ball will hit horizontal or vertical sides before returning to the initial point? For more details/constraints please visit the problem link.
What is the idea/approach to solve this problem? Help appreciated.