//////////////////////////////////////
////       ABHINASH GIRI          ////
/////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define pr 4294967296   // 2^32
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899
#define high 1000000001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             -1e18
#define pinf              1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define e               1000000000
#define w(x)            int t; cin>>t; while(t--)
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define endl "\n"
typedef unsigned long int  ul;
typedef unsigned long long int ull;
typedef unsigned long long  int  li;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<long int> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long int,long int>> vpl;
typedef vector<pair<long long int,long long int>> vpll;
typedef long long ll;
//cout<<"Case #"<<x<<": "<<ans<<endl;
bool cmp(pair<char,int>a,pair<char,int>b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first>b.first;
}
// Fast Exponentiation power(a,b) ==> a to the power b
template <typename T>
T  power(T  a,T  b){
    if(b==0)
        return 1;
    if(b==1)
        return a;
    else{
        T  res=(power(a,b/2));
        if(b%2)
        {
            return (res*res*a);}
        else
        {return res*res;}
    }
}
// Fast Modular Exponentiation  power(a,b,m) ==> (a to the power b) modulo m
template <typename T>
T  power(T  a,T  b,T modulo){
    if(b==0)
        return 1;
    if(b==1)
        return a;
    else{
        T  res=(power(a,b/2,modulo)%modulo);
        if(b%2)
        {
            return ((((res%modulo)*(res%modulo))%modulo)*(a%modulo))%modulo;}
        else
        {return ((res%modulo)*(res%modulo))%modulo;}
    }
}
// G C D
template <typename T>
T  gcd(T  a,T  b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
// L C M
template <typename T>
T lcm(T p, T q)
{
    return (p*q)/gcd<T>(p,q);
}
template <typename T>
T perfect_square(T a)
{
    if(!a or a==1)
    {
        return true;
    }
    T l=2,r=a;
    while(l<=r)
    {
        T m = l+(r-l)/2;
        if((m*m)==a)
        {
            return true;
        }
        else if((m*m)>a)
        {
            r=m-1;
        }
        else { l=m+1;}
    }
    return false;
}
bool valid(string s, int len)
{
    deque<char>se;
    map<char,int>mp;
    mp['1']=0;
    mp['2']=0;
    mp['3']=0;
    // first window of size mid
    for (int j = 0; j <len ; ++j) {
        se.emplace_back(s[j]);
        mp[s[j]]++;
    }
    if(mp['1']>0 and mp['2']>0 and mp['3']>0)
    {
        return true;
    }
    int steps = s.length()-len;
    for (int i = 1; i <=steps ; ++i) {
        se.emplace_back(s[len-1+i]);
        mp[s[len-1+i]]++;
        mp[se.front()]--;
        se.pop_front();
        if(mp['1']>0 and mp['2']>0 and mp['3']>0)
        {
            return true;
        }

    }
   return false;
}
ll mulmod(ll a,ll b,ll c)
{
    //cout<<" solving for "<<a<<" "<<b<<endl;
    // base case if b==0, return 0
    if (b==0)
    {
        //cout<<"returned 0\n";
        return 0;}

    // Divide the problem into 2 parts
    ll s = mulmod(a, b/2, c);

    // If b is odd, return
    // (a+(2*a)*((b-1)/2))%c
    if (b%2==1)
    { ll p = (a%c+2*(s%c)) % c;
    //cout<<" returned "<<p<<endl;
    return p;
    }
        // If b is even, return
        // ((2*a)*(b/2))%c
    else
    { ll  p =(2*(s%c)) % c;
        //cout<<" returned "<<p<<endl;
        return p ;}
}
int main() {
    std::chrono::time_point<std::chrono::high_resolution_clock> start_timer, end_timer;
    start_timer = std::chrono::high_resolution_clock::now();
    bool show_time = false;  //  change it to true when needed;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    /* Cook your Code  */
    fast;
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ll total_min=(h*60)+m;
    //cout<<total_min<<endl;
    double min_angle = double(total_min%60)*6.0*pi/180.0;
    double hr_angle = double(total_min%720)*0.5*pi/180.0;
    double angle = abs(min_angle-hr_angle);
    double ans =sqrt(double(a*a)+double(b*b) -(2.0*a*b*cos(angle)));
    cout<<ps(ans,20)<<endl;
    end_timer = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer-start_timer).count();
    if(show_time)
    {cout << "\nElapsed Time: " << elapsed_time << "ms\n";}

    return 0;
}

Measured memory_bytes: 4204