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

Обсуждение задачи 1093. Дартс

Puzzled by test #5
Послано deserts 12 июл 2004 17:50
I'm sure my source code is perfect. But it never passed test #5. Can anyone help me?

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

int main()
{
        double  cx,cy,cz,nx,ny,nz,r,sx,sy,sz,vx,vy,vz,t;
        double  x,y,z;
        double  a,b,c;
        int     hit;
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&cx,&cy,&cz,&nx,&ny,&nz,&r,&sx,&sy,&sz,&vx,&vy,&vz);
        b=nx*vx+ny*vy+nz*vz;
        c=nx*(sx-cx)+ny*(sy-cy)+nz*(sz-cz);
        a=-5*nz;
        if(b*b-4*a*c<-1e-8)
                printf("MISSED\n");
        else if((b+sqrt(b*b-4*a*c))/nz<-1e-8 && (b-sqrt(b*b-4*a*c))/nz<-1e-8)
                printf("MISSED\n");
        else
        {
                hit=0;
                t=(b-sqrt(b*b-4*a*c))/(10*nz);
                if(t>1e-8)
                {
                        x=sx+vx*t;
                        y=sy+vy*t;
                        z=sz+vz*t-5*t*t;
                        if(r-sqrt(pow(x-cx,2)+pow(y-cy,2)+pow(z-cz,2))>1e-8)
                                ++hit;
                }

                t=(b+sqrt(b*b-4*a*c))/(10*nz);
                if(t>1e-8)
                {
                        x=sx+vx*t;
                        y=sy+vy*t;
                        z=sz+vz*t-5*t*t;
                        if(r-sqrt(pow(x-cx,2)+pow(y-cy,2)+pow(z-cz,2))>1e-8)
                                ++hit;
                }
                if(hit)
                        printf("HIT\n");
                else
                        printf("MISSED\n");
        }
        return 0;
}
Re: Puzzled by test #5
Послано deserts 12 июл 2004 18:17
Solved!
What do you do if a = 0 ?
Послано Vlad Veselov [PMG17, Vinnitsa - KNU, Kiev] 12 июл 2004 18:19
I couldn't pass fifth test too, and I had mistake described above. Maybe, there is another mistake in your program.
Re: Puzzled by test #5
Послано Smilodon_am 21 мар 2009 17:25
The test 5 in TIMUS is the case when the trace of dart only touches the dartboard in one point (i.e. like the parabola touches the plane).

When I had understood this fact I got AC.

Edited by author 21.03.2009 17:26

Edited by author 21.03.2009 17:26
Re: Puzzled by test #5
Послано Cebotari Vladislav 14 дек 2016 19:56
So if it touches the plane should we consider it as a hit?
My solution also fails WA#5 and I don't understand why... any hints guys?