#2573: 這樣判斷有錯嗎??


leopan0922 (zz)

學校 : 臺北市立成功高級中學
編號 : 6612
來源 : [140.113.225.106]
最後登入時間 :
2016-08-15 15:44:07
b073. E. 東方幻想鄉 -- 2007 NPSC 高中組初賽 | From: [58.115.139.238] | 發表日期 : 2009-10-31 11:17

#include <cstdio>  
int input()  
{  
    char cha;  
    int x=0,flag=1;  
    while(cha=getchar())  
    if(cha!=' '&&cha!='\n')  
    break;
    if(cha=='-')
    flag=-1;
    else  
    x=cha-48;  
    while(cha=getchar())  
    {  
        if(cha==' '||cha=='\n')  
        break;  
        x=x*10+cha-48;  
    }  
    return flag*x;  
}          
int main()  
{  
    int n,t,px,py;  
    while(1)  
    {  
       n=input();
       t=input();
       px=input();
       py=input();
       if(n==0&&t==0&&px==0&&py==0)
       break;
       int x,y,vx,vy,hit=0,x1,y1,x2,y2;
       for(;n>0;n--)
       {
           x=input();y=input();vx=input();vy=input();
           if(hit)
           continue;
           vx=x+vx*t;vy=y+vy*t;
           x=x-px;y=y-py;//人到子彈起點的向量
           vx=vx-px;vy=vy-py;//人到子彈終點的向量
           if(x*vy-y*vx==0&&x*vx+y*vy<=0)//若外積=0(表示夾角=0或180)而且內積<=0(表示夾角大於90)則px和py會介在子彈起點到終點的路上
           hit=1;
       }
       if(hit)
       printf("true\n");
       else
       printf("false\n");   
    }              
}               
ZeroJudge Forum