import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double mTHeta = 6 * m; mTHeta 6 * m 6 m double hTheta = 30 * h + 0.5 * m; hTheta 30 * h + 0.5 * m 30 * h 30 h 0.5 * m 0.5 m double theta = Math.abs(hTheta - mTHeta); theta Math.abs(hTheta - mTHeta) Math.abs Math hTheta - mTHeta hTheta mTHeta double ans = 0; ans 0 double bDash = 0; bDash 0 if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } theta == 0 || theta == 360 theta == 0 theta 0 theta == 360 theta 360 ans = Math.abs(b - a) ans Math.abs(b - a) Math.abs Math b - a b a if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } theta == 180 theta 180 ans = b + a ans b + a b a if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } theta > 180 theta 180 {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } theta = 360 - theta theta 360 - theta 360 theta bDash = b - (Math.cos(Math.toRadians(theta)) * a) bDash b - (Math.cos(Math.toRadians(theta)) * a) b (Math.cos(Math.toRadians(theta)) * a) Math.cos(Math.toRadians(theta)) Math.cos Math Math.toRadians(theta) Math.toRadians Math theta a ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a) ans Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a) Math.sqrt Math bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a bDash * bDash bDash bDash Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a Math.sin(Math.toRadians(theta)) Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a Math.sin(Math.toRadians(theta)) Math.sin Math Math.toRadians(theta) Math.toRadians Math theta a Math.sin(Math.toRadians(theta)) Math.sin Math Math.toRadians(theta) Math.toRadians Math theta a {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } bDash = b - (Math.cos(Math.toRadians(theta)) * a) bDash b - (Math.cos(Math.toRadians(theta)) * a) b (Math.cos(Math.toRadians(theta)) * a) Math.cos(Math.toRadians(theta)) Math.cos Math Math.toRadians(theta) Math.toRadians Math theta a ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a) ans Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a) Math.sqrt Math bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a bDash * bDash bDash bDash Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a Math.sin(Math.toRadians(theta)) Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a Math.sin(Math.toRadians(theta)) Math.sin Math Math.toRadians(theta) Math.toRadians Math theta a Math.sin(Math.toRadians(theta)) Math.sin Math Math.toRadians(theta) Math.toRadians Math theta a System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    }
}