#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    #define ll long long
    #define MP make_pair
    #define PB push_back
    #define F first
    #define S second
    #define endl "\n"
    #define MOD 30000000000000000
    #define INF -100000000000000
    #define ordered_set tree<ll int, null_type,less<ll int >, rb_tree_tag,tree_order_statistics_node_update> 
    #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    using namespace std;
    #define hell 1111111111111111111
    #define MAXN 10000005
    #define lld long double
    using namespace __gnu_pbds; 
    ll int power(ll int x,ll int y) 
    { 
        ll int res = 1;     // Initialize result 
       
        while (y > 0) 
        { 
            // If y is odd, multiply x with result 
            if (y & 1) 
                res = res*x; 
       
            // y must be even now 
            y = y>>1; // y = y/2 
            x = x*x;  // Change x to x^2 
        } 
        return res; 
    }
    int spf[MAXN]; 

    //set<ll int> s;
    vector<ll int> ans;
    /*bool prime[10000005];
    void SieveOfEratosthenes(ll int n) 
    { 
        // Create a boolean array "prime[0..n]" and initialize 
        // all entries it as true. A value in prime[i] will 
        // finally be false if i is Not a prime, else true. 
       

        //memset(prime, true, sizeof(prime)); 
      
        for (ll int p=2; p*p<=n; p++) 
        { 
            // If prime[p] is not changed, then it is a prime 
            if (prime[p] == true) 
            { 
                // Update all multiples of p greater than or  
                // equal to the square of it 
                // numbers which are multiple of p and are 
                // less than p^2 are already been marked.  
                for (int i=p*p; i<=n; i += p) 
                    prime[i] = false; 
            } 
        } 
        for(ll int i=2;i<=n;i++)
        {
            if(prime[i]==true)
            {
                mp[i]
            }
        }*/
        // Print all prime numbers 
        

    void sieve() 
    { 
        spf[1] = 1; 
        for (int i=2; i<MAXN; i++) 
      
            // marking smallest prime factor for every 
            // number to be itself. 
            spf[i] = i; 
      
        // separately marking spf for every even 
        // number as 2 
        for (int i=4; i<MAXN; i+=2) 
            spf[i] = 2; 
      
        for (int i=3; i*i<MAXN; i++) 
        { 
            // checking if i is prime 
            if (spf[i] == i) 
            { 
                // marking SPF for all numbers divisible by i 
                for (int j=i*i; j<MAXN; j+=i) 
      
                    // marking spf[j] if it is not  
                    // previously marked 
                    if (spf[j]==j) 
                        spf[j] = i; 
            } 
        } 
    } 
      map< int,int> countt,c1;
    // A O(log n) function returning primefactorization 
    // by dividing by smallest prime factor at every step 
    void getFactorization(int x) 
    { 
        //vector<int> ret;
        map<ll int,ll int> mp; 
        while (x != 1) 
        { 
          //  ret.push_back(spf[x]);
            if(mp[spf[x]]==0)
            {countt[spf[x]]++;

            c1[spf[x]]++;
            mp[spf[x]]++;
            }
            x = x / spf[x]; 
        } 
        //return ret; 
    } 
    int main()
    {
        fast;
      //  #ifndef ONLINE_JUDGE
      //  freopen("input.txt", "r", stdin);
       // freopen("output.txt", "w", stdout);
       // #endif
        lld a,b,h,m;
        cin>>a>>b>>h>>m;
        lld diff,hang,miang,ans;
        lld k=30;
        hang=(h*k+((m*k)/(lld)60));
       // cout<<hang<<endl;
        miang=(((lld)6)*(m));
        if(hang==0)
            hang=(lld)360;
        if(miang==0)
            miang=(lld)360;
        diff=abs(hang-miang);
       // cout<<diff;
       // cout<<cos(diff);
        ans=a*a+b*b-2*a*b*cos(((diff)*(M_PI))/(lld)180);
        cout<<fixed<<setprecision(25)<<sqrt(ans)<<endl;
    }


Measured memory_bytes: 4152