Wednesday, 28 October 2015

Codeforces Gym 100796I - Shell Game Problem_Soultion

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link : http://codeforces.com/gym/100796/problem/I
*/
#include<bits/stdc++.h>
using namespace std;

int main () {
    double h, R, r;
    cin >> r >> R >> h;

    double H = h +(h*r)/(R-r);
    double c = sqrt(H*H+R*R);
    R=R+R;
    double a = 0.5*H*R;
    double s = (R+c+c)*0.5;
    double ans = 2*(a/s);
    ans = min(ans, h);

    printf ("%0.12lf", ans*0.5);
    return 0;
}

No comments:

Post a Comment