Anniversary Cake
Time limit2sMemory limit256 MB
Given a rectangle and two interior candles, output the specific cut described by a fixed rule that separates the candles.
- Level
Easy2 of 10
- Topics
- Geometry, Implementation, Math
- Solved
- No attempts yet
Problem
Adam and Anton are celebrating the second anniversary of failing their Math Logic exam. After a careful search in the local supermarket they bought a rectangular cake with integer side lengths and , and two candles. Place the cake on the plane so that its corners are , , , and .
Adam put the two candles at two different integer points strictly inside the cake and gave Anton a knife. Anton cuts the cake along one straight segment. The cut starts and ends at integer points on the sides of the cake, it must not touch either candle, and each of the two pieces must hold exactly one candle.

The figure shows a cake with candles at and . The drawn cut goes through and and puts the candles in different pieces. Many cuts work, and the output section fixes which one to print.
Input
One line holds six integers , , , , , . The side lengths of the cake are and , the first candle is at , and the second candle is at .
, , , and or .
Output
Print four integers , , , on one line: the start point and the end point of the cut. Both points lie on the sides of the cake.
Many cuts satisfy the conditions, so print only the one fixed by this rule.
- If , let and cut from to .
- If , let and cut from to .
This cut always satisfies the conditions above.