ZOJ1199-Point of Intersection
来源:互联网 发布:网信办网络安全局 编辑:程序博客网 时间:2024/05/17 23:09
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;
Source: Zhejiang University Local Contest 2002, Preliminary
题意:求两圆切线相交点的坐标
解题思路:当半径相同,两圆平行,所以不可以;当圆形距小于半径差,有一圆在另一圆内,所以也不可以
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <cmath>#include <map>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>using namespace std;#define LL long longconst LL INF = 0x3f3f3f3f3f3f3f3f;const double pi = acos(-1.0);const double eps = 1e-8;int main(){int t;double x1, x2, y1, y2, r1, r2;scanf("%d", &t);while (t--){scanf("%lf%lf%lf", &x1, &y1, &r1);scanf("%lf%lf%lf", &x2, &y2, &r2);double dis = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));if (r1 == r2 || dis <= fabs(r1 - r2)){printf("Impossible.\n");continue;}double x;x = r2*dis*1.0 / (r1 - r2);double x3 = (x2 - x1)*x / dis + x2;double y3 = (y2 - y1)*x / dis + y2;printf("%.2lf %.2lf\n", x3, y3);}return 0;}
- zoj1199-Point of Intersection
- ZOJ1199-Point of Intersection
- Point of Intersection
- ZOJ 1199 Point of Intersection
- zoj 1199 Point of Intersection
- ZOJ 1199Point of Intersection
- ZOJ 1199 Point of Intersection(平面几何)
- zoj1199
- zoj 1199 Point of Intersection 求两个圆公切线的交点
- Find the first intersection of two lists (if the two list are merged at some point)
- Intersection of internal tables
- toj3843 Intersection of sets
- lightoj1211 Intersection of Cubes
- Intersection of Two Arrays
- Intersection of Two Arrays
- Intersection of Two Arrays
- Intersection of Two Arrays
- Intersection of Two Arrays
- 输出菱形图案(难度系数:1颗星)
- 使用matplotlib绘制图像并设置标题以及坐标轴等信息
- shu_mj 的数据结构专场(二)
- 《三张表格走天下》读后感
- 大数据排序方案---外排序介绍
- ZOJ1199-Point of Intersection
- E. Interesting Graph and Apples
- Tomcat下web项目部署方式
- cannon算法的原理及MPI C语言实现
- 《三张表格走天下》读书笔记
- IntelliJ IDEA 2017 注册码
- 电子书的Makefile(待分析)
- JDK里其他几个工具
- 基于强化学习的文本生成技术