Quick actions

cmd+k|ctrl+k

Navigation

Languages

fabs py

Snippet info

Language

Python

Visibility

public

Author

vovapskov

Created

2024-12-24T19:31:30.152799Z

Updated

2024-12-24T19:33:42.262462Z

import math

t = int(input())
for i in range(t):
    x, y, c = map(float, input().split())
    left = 0
    right = min(x, y)
    d = (left + right) / 2
  
    while True:
        a = math.sqrt(x * x - d * d)
        b = math.sqrt(y * y - d * d)
        c1 = 1 / ( 1  /a + 1 / b)
        if c1 < c:
            right = (left + right) / 2
        else:
            left = (left + right) / 2
        
        d = (left + right) / 2
        
        if not math.fabs(c1 - c) > 0.00001:
            break
                 
    #print("{:.3f}".format(d))
    print('%.3f' % d)
INFO