https://codeforces.com/contest/215/submission/116490886 was my submission. I thought this would be rejected from the judge, since after a round of math and algebra bashing, answer would be equal to r1/sqrt(A*p2/B*p1+1), and in my answer I simply considered max r1, min p2, max p1 to finish. However, on a longer thought, I should have checked if the square root was positive, but found out all were positive integers so forget it:)