ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1294. Mars Satellites

Please, help me. WA3 ((
Posted by tm15xSat 26 Feb 2012 18:36
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