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;}
- ZOJ 1199 Point of Intersection
- zoj 1199 Point of Intersection
- ZOJ 1199Point of Intersection
- ZOJ 1199 Point of Intersection(平面几何)
- zoj 1199 Point of Intersection 求两个圆公切线的交点
- Point of Intersection
- zoj1199-Point of Intersection
- ZOJ1199-Point of Intersection
- ZOJ 3198 Intersection of Two Sets
- zoj 3198 Intersection of Two Sets
- ZOJ 3198 Intersection of Two Sets
- Find the first intersection of two lists (if the two list are merged at some point)
- ZOJ 3862 Intersection
- ZOJ 3862 Intersection (dijkstra)
- ZOJ-3862-Intersection【贪心】
- zoj 3955 Saddle Point
- CodeForces 600D Area of Two Circles' Intersection 圆面积交 (POJ 2546, ZOJ 1597)
- zoj 3862 Intersection (技巧题)
- 深入浅出Mybatis-与Spring
- 简单模拟实现队列Queue的模板类
- 仿QQ未读消息拖拽删除粘性效果
- Tomcat memcached-session-manager
- CTex使用心得
- ZOJ 1199Point of Intersection
- 无法连接到sqlsever2008 数据库的原因
- RPG角色生成器
- 193. Valid Phone Numbers#1
- conjure-up使用
- 印制板敷铜铜箔种类对插损的影响
- CSS设置滚动条样式
- Android 圆形头像/有外边框的圆形头像CircleImageView自定义控件使用详解
- Javascript函数详解