JOIN

 Problem Statement

Problem Statement for Taxi

### Problem Statement

The "taxicab distance" between two points in space is defined to be the distance that would need to be travelled to get from one to the other using segments that are parallel to the axes. This is generally longer than the (straight-line) distance between the two points.

We know the taxicab distance between two points. We want to know the maximum straight-line distance between them if they lie in the rectangular region { (x,y) | 0<=x<=maxX, 0<=y<=maxY }. Create a class Taxi that contains a method maxDis that is given maxX, maxY, and taxiDis and that returns the largest possible straight-line distance between the two points. If no two points within the given region have the given taxicab distance, return -1.0.

### Definition

 Class: Taxi Method: maxDis Parameters: int, int, int Returns: double Method signature: double maxDis(int maxX, int maxY, int taxiDis) (be sure your method is public)

### Notes

-A return value with either an absolute or relative error of less than 1.0E-9 is considered correct.

### Constraints

-maxX and maxY are both between 1 and 1,000,000, inclusive.
-taxiDis is between 0 and 1,000,000, inclusive.

### Examples

0)

 `10` `3` `3`
`Returns: 3.0`
 The two points could lie in a straight line parallel to one of the axes. Then the straight-line distance would be the same as the taxicab distance.
1)

 `10` `3` `24`
`Returns: -1.0`
 No two points with 0<=x<=10, 0<=y<=3, have a taxicab distance between them that is as big as 24.
2)

 `7` `10` `13`
`Returns: 10.44030650891055`
 (5,0) and (2,10) are two points in this region whose taxicab distance is |2-5| + |10-0| = 13 and whose straight-line distance is sqrt(3*3 + 10*10) = sqrt(109).
3)

 `4` `4` `7`
`Returns: 5.0`
4)

 `976421` `976421` `1000000`
`Returns: 976705.6560100387`

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
Single Round Match 300 Round 1 - Division II, Level One