import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    }
} import java.util.Scanner; Scanner java.util import java.lang.Math; Math java.lang public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    } main {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5; SHORT_HAND_ANGLE_PER_MINUTE 0.5 final double LONG_HAND_ANGLE_PER_MINUTE = 6; LONG_HAND_ANGLE_PER_MINUTE 6 double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE; angleHour (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE (h * 60 + m) h * 60 h 60 m SHORT_HAND_ANGLE_PER_MINUTE double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE; angleMinute m * LONG_HAND_ANGLE_PER_MINUTE m LONG_HAND_ANGLE_PER_MINUTE double eggplantAngle = 0; eggplantAngle 0 if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        } angleHour <= angleMinute angleHour angleMinute {
            eggplantAngle = angleMinute - angleHour;
        } eggplantAngle = angleMinute - angleHour eggplantAngle angleMinute - angleHour angleMinute angleHour {
            eggplantAngle = angleHour - angleMinute;
        } eggplantAngle = angleHour - angleMinute eggplantAngle angleHour - angleMinute angleHour angleMinute if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        } eggplantAngle > 180 eggplantAngle 180 {
            eggplantAngle = 360 - eggplantAngle;
        } eggplantAngle = 360 - eggplantAngle eggplantAngle 360 - eggplantAngle 360 eggplantAngle double radian = Math.toRadians(eggplantAngle); radian Math.toRadians(eggplantAngle) Math.toRadians Math eggplantAngle double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian)); c Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian)) Math.sqrt Math Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian) Math.pow(a,2) + Math.pow(b,2) Math.pow(a,2) Math.pow Math a 2 Math.pow(b,2) Math.pow Math b 2 2 * a * b * Math.cos(radian) b 2 * a * b * Math.cos(radian) 2 a b Math.cos(radian) Math.cos Math radian System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    }
} public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    }
} Main
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    }
}
