Lazy Supermen

There are two hills in Sonargaon. The heights of them are H1 and H2 meter. The distance between the …

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

I think this problem can’t be solved with python.

Here is my code:

import math


num_test = int(input())
for i in range(num_test):
    h1, h2, distance = map(int, input().split())
    min_h1 = distance**2 + h1**1
    min_h2 = distance**2 + h2**2
    for j in range(distance+1):
        a = math.sqrt(h1**2 + j**2)
        b = math.sqrt(h2**2 + (distance - j)**2)
        if a + b < min_h1 + min_h2:
            min_h1 = float(str.format('{0:.4f}', a))
            min_h2 = float(str.format('{0:.4f}', b))
    print(min_h1)
    print(min_h2)

Maybe… That’s because the H1, H2 and D inputs are not inline… As for C++ it adjusts…