Under construction

Still being built. Things may change

Constructing a Cyclic Quadrilateral

Time limit1sMemory limit512 MB

Summary
Given three decreasing segment lengths where the longest is a diameter of the circumscribed circle, find the fourth side of the cyclic quadrilateral or print -1.
Level

Easy3 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

A quadrilateral is cyclic if its four vertices lie on a circle. You are given the lengths of three line segments, and the longest of them equals the diameter of the circle on which the quadrilateral is inscribed. Find the length of the remaining segment.

Input

The first line contains three integers a,b,ca, b, c representing the lengths of the three segments. (1≤a,b,c≤1001 \le a, b, c \le 100) The three segments are given in decreasing order.

Output

Print the length of the remaining side on the first line. If no cyclic quadrilateral can be formed, print -1. The answer is guaranteed to be an integer in every test case.

Hint

By Ptolemy's theorem, for a cyclic quadrilateral the sum of the products of the two pairs of opposite sides equals the product of the two diagonals.

Examples3

  1. Example 1

    Input
    2 1 1
    
    Expected output
    1
    
  2. Example 2

    Input
    1 1 1
    
    Expected output
    -1
    
  3. Example 3

    Input
    72 42 23
    
    Expected output
    42