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 1093. Darts

This problem seems to be quite easy and i almost sure in the correctness of my program....BUT WA!!!!!!SO HELPHELPHELPHELP
Posted by King Without Kingdom 3 Aug 2002 07:59
This is my code:
#include<iostream.h>
#include<math.h>
//ifstream fin("input.txt");
long double cx,cy,cz,nx,ny,nz,r,sx,sy,sz,vx,vy,vz;
int main(){
    cin >>cx >> cy >> cz >>nx >>ny >>nz >>r >>sx >>sy >>sz >>vx
>>vy >>vz;
    cx-=sx;
    cy-=sy;
    cz-=sz;
    long double V=(nx*vx+ny*vy+nz*vz)/sqrtl(nx*nx+ny*ny+nz*nz);
    long double G=-(10*nz)/sqrtl(nx*nx+ny*ny+nz*nz);
    long double L=(cx*nx+cy*ny+cz*nz)/sqrtl(nx*nx+ny*ny+nz*nz);
    if(V*V+2*L*G<0)
    {
        cout << "MISSED\n";
        return 0;
    }
    long double t=(-V+sqrtl(V*V+2*L*G))/G;
    if(t>=0)
        {
            long double xp=vx*t-cx;
            long double yp=-cy+vy*t;
            long double zp=-cz+vz*t-5*t*t;
            if((xp)*(xp)+(yp)*(yp)+(zp)*(zp)<r*r)
                {
                    cout << "HIT\n";
                    return 0;
                }
        }
    t=(-V-sqrtl(V*V+2*L*G))/G;
    if(t>=0)
        {
            long double xp=-cx+vx*t;
            long double yp=-cy+vy*t;
            long double zp=-cz+vz*t-5*t*t;
            if((xp)*(xp)+(yp)*(yp)+(zp)*(zp)<r*r)
                {
                    cout << "HIT\n";
                    return 0;
                }
        }
    cout << "MISSED\n";
    return 0;
}

Oh there really was small bug in my program now i get ac
Posted by King Without Kingdom 3 Aug 2002 08:16
> This is my code:
> #include<iostream.h>
> #include<math.h>
> //ifstream fin("input.txt");
> long double cx,cy,cz,nx,ny,nz,r,sx,sy,sz,vx,vy,vz;
> int main(){
>     cin >>cx >> cy >> cz >>nx >>ny >>nz >>r >>sx >>sy >>sz >>vx
> >>vy >>vz;
>     cx-=sx;
>     cy-=sy;
>     cz-=sz;
>     long double V=(nx*vx+ny*vy+nz*vz)/sqrtl(nx*nx+ny*ny+nz*nz);
>     long double G=-(10*nz)/sqrtl(nx*nx+ny*ny+nz*nz);
>     long double L=(cx*nx+cy*ny+cz*nz)/sqrtl(nx*nx+ny*ny+nz*nz);
>     if(V*V+2*L*G<0)
>     {
>         cout << "MISSED\n";
>         return 0;
>     }
>     long double t=(-V+sqrtl(V*V+2*L*G))/G;
>     if(t>=0)
>         {
>             long double xp=vx*t-cx;
>             long double yp=-cy+vy*t;
>             long double zp=-cz+vz*t-5*t*t;
>             if((xp)*(xp)+(yp)*(yp)+(zp)*(zp)<r*r)
>                 {
>                     cout << "HIT\n";
>                     return 0;
>                 }
>         }
>     t=(-V-sqrtl(V*V+2*L*G))/G;
>     if(t>=0)
>         {
>             long double xp=-cx+vx*t;
>             long double yp=-cy+vy*t;
>             long double zp=-cz+vz*t-5*t*t;
>             if((xp)*(xp)+(yp)*(yp)+(zp)*(zp)<r*r)
>                 {
>                     cout << "HIT\n";
>                     return 0;
>                 }
>         }
>     cout << "MISSED\n";
>     return 0;
> }
>
>
>
what's bug in this program??
Posted by hawking 21 Aug 2002 16:29
Re: what's bug in this program??
Posted by KHU$R@V 7 Jan 2014 10:53