/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
public class Main {
public static double distance ( double X1,double X2,double Y1,double Y2)
{
return ( Math .
sqrt ( ( X1
- X2
) * ( X1
- X2
) + ( Y1
- Y2
) * ( Y1
- Y2
) ) ) ; }
public static void main
( String [ ] args
) { Scanner sc
= new Scanner
( System .
in ) ; double A = sc.nextDouble ( ) ;
double B = sc.nextDouble ( ) ;
double C = sc.nextDouble ( ) ;
double X1 = sc.nextDouble ( ) ;
double Y1 = sc.nextDouble ( ) ;
double X2 = sc.nextDouble ( ) ;
double Y2 = sc.nextDouble ( ) ;
double Z2 = sc.nextDouble ( ) ;
double result_distance
= Double .
MAX_VALUE ; if ( Z2== 0 ) result_distance = distance( X1,X2,Y1,Y2) ; //"floor" case
else
{
if ( X2== 0 ) {
X2=- Z2;
result_distance = distance ( X1,X2,Y1,Y2) ;
} //"left wall" case
if ( X2== A) {
X2= A+ Z2;
result_distance = distance ( X1,X2,Y1,Y2) ;
} //"right wall" case
if ( Y2== 0 ) {
Y2=- Z2;
result_distance
= Math .
min ( result_distance, distance
( X1,X2,Y1,Y2
) ) ; } //"near wall" case
if ( Y2== B) {
Y2= B+ Z2;
result_distance
= Math .
min ( result_distance, distance
( X1,X2,Y1,Y2
) ) ; } //"distant wall" case
}
System .
out .
printf ( "%.2f" , result_distance
) ; }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgoKcHVibGljIGNsYXNzIE1haW4gewogICAgcHVibGljIHN0YXRpYyBkb3VibGUgZGlzdGFuY2UgKGRvdWJsZSBYMSxkb3VibGUgWDIsZG91YmxlIFkxLGRvdWJsZSBZMikKICAgIHsKICAgICAgICByZXR1cm4gKE1hdGguc3FydCgoWDEtWDIpKihYMS1YMikrKFkxLVkyKSooWTEtWTIpKSk7CiAgICB9CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgZG91YmxlIEEgPSBzYy5uZXh0RG91YmxlKCk7CiAgICAgICAgZG91YmxlIEIgPSBzYy5uZXh0RG91YmxlKCk7CiAgICAgICAgZG91YmxlIEMgPSBzYy5uZXh0RG91YmxlKCk7CiAgICAgICAgZG91YmxlIFgxID0gc2MubmV4dERvdWJsZSgpOwogICAgICAgIGRvdWJsZSBZMSA9IHNjLm5leHREb3VibGUoKTsKICAgICAgICBkb3VibGUgWDIgPSBzYy5uZXh0RG91YmxlKCk7CiAgICAgICAgZG91YmxlIFkyID0gc2MubmV4dERvdWJsZSgpOwogICAgICAgIGRvdWJsZSBaMiA9IHNjLm5leHREb3VibGUoKTsKICAgICAgICBkb3VibGUgcmVzdWx0X2Rpc3RhbmNlID0gRG91YmxlLk1BWF9WQUxVRTsKICAgICAgICBpZiAoWjI9PTApIHJlc3VsdF9kaXN0YW5jZSA9IGRpc3RhbmNlKFgxLFgyLFkxLFkyKTsvLyJmbG9vciIgY2FzZQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIGlmIChYMj09MCkgewogICAgICAgICAgICAgICAgWDI9LVoyOwogICAgICAgICAgICAgICAgcmVzdWx0X2Rpc3RhbmNlID0gZGlzdGFuY2UgKFgxLFgyLFkxLFkyKTsKICAgICAgICAgICAgfS8vImxlZnQgd2FsbCIgY2FzZQogICAgICAgICAgICBpZiAoWDI9PUEpIHsKICAgICAgICAgICAgICAgIFgyPUErWjI7CiAgICAgICAgICAgICAgICByZXN1bHRfZGlzdGFuY2UgPSBkaXN0YW5jZSAoWDEsWDIsWTEsWTIpOwogICAgICAgICAgICB9Ly8icmlnaHQgd2FsbCIgY2FzZQogICAgICAgICAgICBpZiAoWTI9PTApIHsKICAgICAgICAgICAgICAgIFkyPS1aMjsKICAgICAgICAgICAgICAgIHJlc3VsdF9kaXN0YW5jZSA9IE1hdGgubWluKHJlc3VsdF9kaXN0YW5jZSwgZGlzdGFuY2UgKFgxLFgyLFkxLFkyKSk7CiAgICAgICAgICAgIH0vLyJuZWFyIHdhbGwiIGNhc2UKICAgICAgICAgICAgaWYgKFkyPT1CKSB7CiAgICAgICAgICAgICAgICBZMj1CK1oyOwogICAgICAgICAgICAgICAgcmVzdWx0X2Rpc3RhbmNlID0gTWF0aC5taW4ocmVzdWx0X2Rpc3RhbmNlLCBkaXN0YW5jZSAoWDEsWDIsWTEsWTIpKTsKICAgICAgICAgICAgfS8vImRpc3RhbnQgd2FsbCIgY2FzZQogICAgICAgIH0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50ZigiJS4yZiIsIHJlc3VsdF9kaXN0YW5jZSk7CiAgICB9Cn0K