VPEX P3 - Coding Club
At coding club, Darcy is watching the bouncing screensaver meme. The screensaver consists of rectangular DVD logo of width ~A~ and height ~B~ bouncing around a rectangular screen of width ~W~ and height ~H~ at a speed of ~1~ unit/second. When the logo touches a side of the screen, it bounces off such that the angle of incidence equals the angle of reflection. When the logo reaches a corner, its direction is simply reversed.
The logo begins at position ~(x_0,y_0)~ (measured from the bottom left corner of the screen and logo) and travels in the direction ~(x,y)~. After a while, Darcy noticed that the logo returned to it's starting position and velocity. What is the minimum time Darcy had to wait?
The first line contains integers ~W~ and ~H~, the width and height of the screen.
The second line contains integers ~A~ and ~B~, the width and height of the logo.
The third line contains integers ~x_0~ and ~y_0~, representing the starting position of the logo (measured from the bottom left corner of the screen to the bottom left corner of the logo).
The last line contains integers ~x~ and ~y~, meaning the logo has the same initial direction as an vector pointing ~x~ units right and ~y~ units up.
Let ~T~ be the minimum amount of seconds after beginning such that the logo is at position ~(x_0,y_0)~ travelling in direction ~(x,y)~. Print the 6 digits beginning from the first non-zero digit of ~T~.
If this will never happen, print
~1\le A< W\le1000~
~1\le B< H\le1000~
~1\le A+x_0\le W~
~1\le B+y_0\le H~
~x\neq 0~ or ~y\neq 0~
Subtask 1 [20%]
~1\le W,H,x,y\le 15~
11 11 1 1 5 5 1 1