#P6483. [COCI 2010/2011 #4] PARKET

[COCI 2010/2011 #4] PARKET

Description

There is an nn by mm grid. The cells on the outer border are red, and all other cells are black.

Given the number of red cells rr and the number of black cells bb, find a feasible pair of values nn and mm.

Input Format

The input consists of one line with two integers, representing the number of red cells rr and the number of black cells bb.

Output Format

Output one line with two integers, representing the number of rows nn and the number of columns mm of the grid. If there are multiple solutions, output the one with the largest nn.

8 1

3 3
10 2

4 3
24 24

8 6

Hint

Explanation of Sample 2

The output grid is shown in the figure: light-colored cells represent red, and dark-colored cells represent black.

Constraints

For all testdata, it is guaranteed that 8r2×1068 \leq r \leq 2 \times 10^6 and 1b2×1061 \leq b \leq 2 \times 10^{6}. It is guaranteed that at least one solution exists.

Note

This problem is translated from COCI2010-2011 CONTEST #4 T2 PARKET. Translation by @一扶苏一.

Translated by ChatGPT 5