VPEX P3 - Coding Club

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 0.5s
Memory limit: 64M

Problem types

diagram

At coding club, Darcy is watching the bouncing screensaver meme. The screensaver consists of a 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 (x0,y0) (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 its starting position and velocity. What is the minimum time Darcy had to wait?

Input Specification

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 x0 and y0, 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 a vector pointing x units right and y units up.

Output Specification

Let T be the minimum amount of seconds after beginning such that the logo is at position (x0,y0) 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.

Constraints

1A<W1000
1B<H1000
1A+x0W
1B+y0H
105x,y105
x0 or y0

Subtask 1 [20%]

1W,H,x,y15

Sample Input

Copy
11 11
1 1
5 5
1 1

Sample Output

Copy
282842

Explanation

T=28.2842712


Comments

There are no comments at the moment.