Rectangular polygon
InterviewTime limit2sMemory limit1024 MB
Given area S and perimeter P, find integer side lengths a and b (a >= b) of a rectangle with those values, or print -1 if none exist.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Statement
Recently, to improve training for the armed forces of A-landia, it was decided to rebuild one of the abandoned military training grounds. Part of the design documents kept in the archives shows that the ground is rectangular. The experts worked out its area from the types of weapons tested there, and its perimeter from the amount of barbed wire used to fence it. The area is an integer number of square meters, and the perimeter is an integer number of meters.
Your task is to find the side lengths of the ground, given that each side is also an integer number of meters.
Input
The first line of the input file contains two integers and , the area in square meters and the perimeter in meters of the ground. , .
Output
If there exist integers and () such that a rectangle with sides and has area and perimeter , print these two numbers on the first line of the output file. Otherwise (if no rectangle with the given area and perimeter exists, or its sides are not integers), print a single number .