## VPEX P3 - Coding Club

View as PDF

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

Author:
Problem types

At coding club, Darcy is watching the bouncing screensaver meme. The screensaver consists of rectangular DVD logo of width and height bouncing around a rectangular screen of width and height at a speed of 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 (measured from the bottom left corner of the screen and logo) and travels in the direction . 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?

#### Input Specification

The first line contains integers and , the width and height of the screen.
The second line contains integers and , the width and height of the logo.
The third line contains integers and , 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 and , meaning the logo has the same initial direction as an vector pointing units right and units up.

#### Output Specification

Let be the minimum amount of seconds after beginning such that the logo is at position travelling in direction . Print the 6 digits beginning from the first non-zero digit of .

If this will never happen, print -1.

or

#### Sample Input

11 11
1 1
5 5
1 1

#### Sample Output

282842