PersonalCorpus 版 (精华区)

Your C++ program has solved Ok the problem 10357 (Playball !!!)
in 0.002 seconds with low memory spent.


double dis(double a, double b, double c, double d)
{
    return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}

void main()
{

    int i,j,k,t,n;
    double player[20][3],a,b,c,d,e,f,g,x,y;

    scanf("PLAYERS=%d\n",&n);
    for (i=0;i<n;i++) scanf("%lf%lf%lf\n",&player[i][0],&player[i][1],
&player[i][2]);
    scanf("BALLS=%d\n",&t);
    for (i=1;i<=t;i++) {
        scanf("%lf%lf%lf%lf%lf%lf%lf\n",&a,&b,&c,&d,&e,&f,&g);
        j=ceil( (-b-(sqrt(b*b-4*a*c)))/2/a );
        x=d*j+e;
        y=f*j+g;
        if ((x<0)||(y<0)) {
            printf("Ball %d was foul at (%.0lf,%.0lf)\n",i,x,y);
            continue;
        }
        for (k=0;k<n;k++) if (dis(x,y,player[k][0],
player[k][1])<=player[k][2]*j) break;
        if (k==n) {
            printf("Ball %d was safe at (%.0lf,%.0lf)\n",i,x,y);
        } else {
            printf("Ball %d was caught at (%.0lf,%.0lf)\n",i,x,y);
        }
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:5.952毫秒