Problem list
Log in
#coci00170 · COCI 2010/2011 Contest 4

Parket

Bronze II 1.0 s 32 MB

Ivica has set up a new parquet flooring in his room. The room is $L$ decimeters long and $W$ decimeters wide.

The blocks are of quadratic shape and each has an area of one quadratic decimeter. Once Ivica had set up the flooring, which consists of brown-colored blocks, he decided to paint the blocks on the edge of the room red.

For example, in a room of size $4 \times 3$ the outer blocks are red, while the remaining two inner blocks are brown.

Marica has come to visit Ivica. While Ivica was serving her cookies, she counted the number of blocks of each color. When she returned home, she recalled the two numbers and wished to calculate the dimensions of Ivica's room. Help her!

Input

The first and only line of input contains two integers separated by a space, $R$ (the number of red blocks) and $B$ (the number of brown blocks), with $8 \le R \le 5000$ and $1 \le B \le 2,000,000$.

Output

The first and only line of output must contain the dimensions of the room, $L$ and $W$, respectively. If the numbers differ, output the greater one first. The test data will ensure that a unique solution always exists.

Scoring: In test cases worth $30%$ of total points, the dimensions $L$ and $W$ will be equal.

Example 1

Input
8 1
Output
3 3

Example 2

Input
10 2
Output
4 3

Example 3

Input
24 24
Output
8 6
Source
COCI 2010/2011 Contest 4
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code