ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1075. Нитка в пространстве

I wrote a program, but I got WA. Maybe there are some problems with presision.
Послано Aleksei Zobnin 17 янв 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.
Послано A. Mironenko 24 янв 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.
Послано Aleksei Zobnin 26 янв 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.
Послано A. Mironenko 15 окт 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.