Answer:
The equations for the y position of the trajectory is:

The range is of the trajectory is reached at y = 0:

Solving for time t:

The x position of the trajectory is given by:

Combining the equations we get the function:

Taking the derivative and setting it to zero:

Find the maximum angle:

Using this solution to find the trajectory in terms of x and y and setting it equal to height h:

Normalize:

Use quadratic formula:

The distance is the difference between the two points:

