ural 1294 Mars Satellites

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <algorithm>
 5 using namespace std;
 6 const double eps=1e-8;
 7 
 8 int main()
 9 {
10     double a,b,c,d;
11     scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
12     a*=1000.0; b*=1000.0; c*=1000.0; d*=1000.0;
13     if(fabs(c*d-a*b)<eps)
14     {
15         printf("Impossible.\n");
16     }
17     else
18     {
19         printf("Distance is %.0lf km.\n",sqrt((c*d*(a*a+b*b)-a*b*(c*c+d*d))/(c*d-a*b)));
20     }
21     return 0;
22 }
View Code

 

posted @ 2014-03-24 19:43  null1019  阅读(155)  评论(0编辑  收藏  举报