ZOJ 1199Point of Intersection

来源:互联网 发布:28岁程序员 压力大 编辑:程序博客网 时间:2024/05/01 01:04

Given two circles on the same plane which are centered at (x1,y1) and (x2,y2) ,with radiuses r1 and r2, respectively.We can see that they have two common tangent lines in most of the cases.Now you are asked to write a programme to calculate the point of intersection of the two tangents if there exists one. ( See Figure 1 )

Figure. 1 Point of intersection


Input

The input data consists of the information of several figures.The first line of the input contains the number of figures. 
Each figure is described by two lines of data.Each line contains 3 integers constituting the coordinates of the center (x, y) and the radius r (>0) of a circle.

Output

For each figure, you are supposed to output the coordinates (x, y) of the point of intersection if it exists.The x and y must be rounded to two decimal places and be separated by one space.If there is no such point exists simply output "Impossible."

Sample Input

20 0 100 0 50 0 1010 0 1


Output for the Sample Input

Impossible.11.11 0.00

Notice

The common tangent lines like the following figure don't take into account;


无聊的几何题,推公式就行了。

#include<map>#include<cstring>#include<cstdio>#include<algorithm>#include<math.h>using namespace std;long long a1,a2,b1,b2,r1,r2;int main(){    int _;    scanf("%d",&_);    while(_--)    {        scanf("%lld%lld%lld",&a1,&b1,&r1);        scanf("%lld%lld%lld",&a2,&b2,&r2);        if(r1==r2||(r1-r2)*(r1-r2)>=(a1-a2)*(a1-a2)+(b1-b2)*(b1-b2)) puts("Impossible.");        else        {            if(r1<r2)            {                swap(a1,a2);                swap(b1,b2);                swap(r1,r2);            }            double d1=(a1-a2)*(a1-a2)+(b1-b2)*(b1-b2);            d1=sqrt(d1);            double d=d1*r2/(r1-r2);            double k1=1.0*(b2-b1);            double k2=1.0*(a2-a1);            printf("%.2lf %.2lf\n",a2+d*k2/sqrt(k1*k1+k2*k2),b2+d*k1/sqrt(k1*k1+k2*k2));        }    }    return 0;}


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 论文被别人抄袭怎么办 冒充网警诈骗怎么办 南师大自发挂了怎么办 中学生沉迷手机游戏怎么办? 孩子花钱玩游戏怎么办 mykung充不了电怎么办 脑出血恢复期身体软怎么办 腿里面有积水怎么办 手臂伤筋了怎么办 想打羽毛球没人怎么办 对看书没有兴趣怎么办 痴呆老人晚上闹怎么办 高中毕业证没拿怎么办 高考志愿同分怎么办 儿童吃虾过敏怎么办 滑板湿水了怎么办 老员工不听指挥怎么办 手机显示连接itunes怎么办 苹果手机下载不信任怎么办 暗影格斗3进不去怎么办 喝酒第二天头痛怎么办 加油忘记拔枪怎么办 刷机完成后怎么办 苹果8按键音太小怎么办 电脑蓝屏出英文怎么办 win10蓝屏重启怎么办 苹果手机变蓝屏怎么办 nga账号声望不足怎么办 鬃狮蜥胆小咬人怎么办 小狗拉稀脱水了怎么办 泰迪刚到家老叫怎么办 开车遇到拉死人怎么办 斯诺克解不到球怎么办 颈椎和腰椎不好怎么办 车祸肇事者不赔偿怎么办 交强险自赔吃亏怎么办 交通事故保险不结案怎么办 马蚁借呗超出一天还款怎么办 千里追风油太辣怎么办 蛀牙牙肉肿痛怎么办 转转删除的东西怎么办