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 1075. Thread in a Space

I wrote a program, but I got WA. Maybe there are some problems with presision.
Posted by Aleksei Zobnin 17 Jan 2002 13:08
Could anybody tell me the trick?
Re: I wrote a program, but I got WA. Maybe there are some problems with presision.
Posted by A. Mironenko 24 Jan 2002 19:43
> Could anybody tell me the trick?

writeln (answer:10:2)
Re: I wrote a program, but I got WA. Maybe there are some problems with presision.
Posted by Aleksei Zobnin 26 Jan 2002 22:31
> > Could anybody tell me the trick?
>
> writeln (answer:10:2)

I know that. But there are some other problems...
Here's my code:


#include <stdio.h>
#include <math.h>

typedef struct TPoint {
 long double X, Y, Z;
} TPoint;

const long double Eps = 1e-50;

TPoint A, B, O;
long double R, Phi, CosPhi, L, AO, BO, AB, H;

long double Sqr (long double X) {
 return X * X;
}

long double Dist (TPoint A, TPoint B) {
 return sqrtl (Sqr (A.X - B.X) + Sqr (A.Y - B.Y) + Sqr (A.Z - B.Z));
}

int main () {
 scanf ("%Lf%Lf%Lf", &(A.X), &(A.Y), &(A.Z));
 scanf ("%Lf%Lf%Lf", &(B.X), &(B.Y), &(B.Z));
 scanf ("%Lf%Lf%Lf", &(O.X), &(O.Y), &(O.Z));
 scanf ("%Lf", &R);
 AO = Dist (A, O);
 BO = Dist (B, O);
 AB = Dist (A, B);
 if (AB < Eps) {
  printf ("0.00\n");
  return 0;
 }
 CosPhi = ((A.X - O.X) * (B.X - O.X) + (A.Y - O.Y) * (B.Y - O.Y) +
(A.Z - O.Z) * (B.Z - O.Z))
   / (AO * BO);
 Phi = acosl (CosPhi);
 H = AO * BO * sqrtl (1 - Sqr(CosPhi)) / AB;
 if (H < R - Eps) {
  Phi -= acosl (R / AO) + acosl (R / BO);
  if (Phi < 0) Phi = 0;
  L = sqrtl (Sqr (AO) - Sqr (R)) + sqrtl (Sqr (BO) - Sqr (R)) + R *
Phi;
 } else L = AB;
 printf ("%.2Lf\n", L);
 return 0;
}
Re: I wrote a program, but I got WA. Maybe there are some problems with presision.
Posted by A. Mironenko 15 Oct 2002 21:01
> > > Could anybody tell me the trick?
> >
> > writeln (answer:10:2)
>
> I know that. But there are some other problems...
> Here's my code:


There should be a bit more if's.