PARKET1  PARKET
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.
The picture below illustrates the scenario from the test case #2 – 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 of 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). The following constraints will apply: 8 ≤ R ≤ 5000, 1 ≤ B ≤ 2*10^{6}.
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.
input 1: 8 1 output 1: 3 3
input 2: 10 2 output 2: 4 3
hide comments
codequant:
20190927 09:34:18
Piece of cake, just use area and perimeter formula and find the relation. Loop & find the integer which satisfies the relation. 

ash_demon8:
20180512 16:00:55
easy maths... ac in one go... think from basic:) 

divyaprakash18:
20161127 19:10:01
Fun math derivation + 5 lines code ;) 

nonushikhar:
20160712 16:37:25
move this to tutorial :) 

manohar_4139:
20160621 11:48:46
only formula gets AC:( 

suresh_india7:
20160109 20:07:28
hint:let actual length and width are x & y ;) 

Arnab Mitra:
20150619 05:51:25
Mathematically derive the formula. After that 2 min coding. 

Rishabh Joshi:
20150617 20:03:12
Maths. 5 min formula derivation, 5 min coding. 

Erik Lonèarek:
20150121 02:06:30
Picture and full problem specification available on: http://www.hsin.hr/coci/archive/2010_2011/contest4_tasks.pdf 
Added by:  Kawmia Institutes 
Date:  20110219 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  COCI 