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

wa3 (((
Posted by Egor Stepanov [mikroz] 13 Nov 2008 19:20
What's wrong???

my code:

#include <cstdio>
#include <cmath>

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  if (a * b == c * d) {
    printf("Impossible.\n");
  } else {
    double cos = (a * a * 1.0 + b * b - c * c - d * d) / (2 * a * b - 2 * c * d);
    double x = a * a * 1.0 + b * b - 2 * a * b * cos;

    if (x < 0)
      printf("Impossible.\n");
    else
      printf("Distance is %d km.\n", (int)(sqrt(x) * 1000));
  }
}