Gift Box (UVA 13053) by return_zukky
Contest: 3738    RunID: 20175116    Status: Accepted    Date: Sat Oct 14 18:13:21 JST 2017


#include<bits/stdc++.h>
using namespace std;

const double EPS=1e-8;
typedef complex<double> P;
typedef pair<P,P> L;

double cross(P a, P b){ return imag(conj(a) * b); }

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

int main(){
  
  int T=1,t;
  
  cin>>t;

  while(t--){
    
    double a, b, c;
    cin>>a>>b>>c;
    
    P A = P(a/2, b+c/2);
    P B = P(a+c/2, b+c+b/2);
    
    L L1 = L(P(0,0), P(0,1));
    L L2 = L(P(a*2+c*2,0), P(a*2+c*2,1));
    L L3 = L(A, B);
    
    P p1 = crossPoint(L1, L3);
    P p2 = crossPoint(L2, L3);
    
    cout<<"Case "<<T++<<": ";
    printf("%.8f\n", abs(p1-p2));
    
  }
  
  return 0;
}