PersonalCorpus 版 (精华区)

43947 2002-10-21 14:37:31 Accepted
1199 C++ 00:00.00 388K Big Guava 


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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\0acm\\zju\\i1199","r",stdin);
    freopen("c:\\0acm\\zju\\o1199","w",stdout);
#endif

    int i,j,k,n;
    double x,y,x1,y1,r1,x2,y2,r2;

    scanf("%d\n",&n);
    while (n--) {
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);
        if ((distance(x1,y1,x2,y2)<=fabs(r1-r2))||(r1==r2)) {
            printf("Impossible.\n");
        } else {
            if (r1>r2) {
                x=r1*(x1-x2)/(r2-r1)+x1;
                y=r1*(y1-y2)/(r2-r1)+y1;
            } else {
                x=r2*(x2-x1)/(r1-r2)+x2;
                y=r2*(y2-y1)/(r1-r2)+y2;
            }
            printf("%.2lf %.2lf\n",x,y);

        }
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.500毫秒