|  | 
|  | 
| вернуться в форум | Please, help me. WA3 (( what is wrong???
 #include <iostream>
 #include <cmath>
 using namespace std;
 
 int main ()
 {
 int a, b, c, d;
 cin >> a >> b >> c >> d;
 if (a*b == c*d)
 {
 cout << "Impossible.";
 return 0;
 }
 
 double s;
 s = (c*d*a*a + c*d*b*b - a*b*c*c - a*b*d*d)/(c*d-a*b);
 if (s < 0)
 {
 cout << "Impossible.";
 return 0;
 }
 
 int ans;
 s = (sqrt(s) * 1000);
 if (s - (int)s < 0.5)
 ans = (int)s;
 else
 ans = (int)s + 1;
 cout << "Distance is " << ans << " km.";
 return 0;
 }
 
 Edited by author 26.02.2012 18:37
 | 
 | 
|