A Math Contest P6 - Global Maximum

View as PDF

Submit solution

Points: 10
Time limit: 0.5s
Memory limit: 512M

Problem type

You are given integers N and M. Among all real solutions (a, b, c, d) to the equations a + b + c + d = N and a^2 + b^2 + c^2 + d^2 = M, what is the maximal value of d?


-10^3 \le N \le 10^3

0 \le M \le 10^6

Input Specification

The only line contains two space-separated integers, N and M.

Output Specification

If there are no solutions, output no; otherwise, output the maximal value of d.

Your answer will be accepted if the absolute error is within 10^{-6}.

Sample Input

7 13

Sample Output


Explanation for Sample

The maximal value of d is reached at (a, b, c, d) = (1.5, 1.5, 1.5, 2.5).


There are no comments at the moment.