Problem B Common Tangents

Accept: 191    Submit: 608
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Two different circles can have at most four common tangents.

The picture below is an illustration of two circles with four common tangents.

Now given the center and radius of two circles, your job is to find how many common tangents between them.

Input

The first line contains an integer T, meaning the number of the cases (1 <= T <= 50.).

For each test case, there is one line contains six integers x1 (−100 ≤ x1 ≤ 100), y1 (−100 ≤ y1 ≤ 100), r1 (0 < r1 ≤ 200), x2 (−100 ≤ x2 ≤ 100), y2 (−100 ≤ y2 ≤ 100), r2 (0 < r2 ≤ 200). Here (x1, y1) and (x2, y2) are the coordinates of the center of the
first circle and second circle respectively, r1 is the radius of the first circle and r2 is the radius of the second circle.

Output

For each test case, output the corresponding answer in one line.

If there is infinite number of tangents between the two circles then output -1.

Sample Input

3
10 10 5 20 20 5
10 10 10 20 20 10
10 10 5 20 10 5

Sample Output

4
2
3

判断两个圆有几条切线!有一点需要注意,两个圆重合的时候输出-1,重合时有无数条切线,水题一枚

#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int x1,x2,y1,y2,r1,r2;
double s1;
scanf("%d%d%d%d%d%d",&x1,&y1,&r1,&x2,&y2,&r2);
if(x1==x2&&y1==y2&&r1==r2)
printf("-1\n");
else
{
s1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
if(r1+r2<s1)
printf("4\n");
else if(r1+r2==s1)
printf("3\n");
else if(r1+r2>s1)
{
if(s1+min(r1,r2)==max(r1,r2))
printf("1\n");
else if(s1+min(r1,r2)<max(r1,r2))
printf("0\n");
else printf("2\n");
}
}
}
return 0;
}



福建省赛-- Common Tangents(数学几何)的更多相关文章

  1. FZU 2213——Common Tangents——————【两个圆的切线个数】

    Problem 2213 Common Tangents Accept: 7    Submit: 8Time Limit: 1000 mSec    Memory Limit : 32768 KB ...

  2. hdu 1577 WisKey的眼神 (数学几何)

    WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  3. FZU 2213 Common Tangents(公切线)

    Description 题目描述 Two different circles can have at most four common tangents. The picture below is a ...

  4. hdu 1115 Lifting the Stone (数学几何)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  5. ACdream区域赛指导赛之专题赛系列(1)の数学专场

    Contest : ACdream区域赛指导赛之专题赛系列(1)の数学专场 A:EOF女神的相反数 题意:n(<=10^18)的数转化成2进制.翻转后(去掉前导零)输出十进制 思路:water ...

  6. 2018 ICPC上海大都会赛重现赛 D Thinking-Bear magic (几何)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 D Thinking-Bear magic (几何) 链接:https://ac.nowcoder.com/acm/contest/163/ ...

  7. FZU 2213 Common Tangents 第六届福建省赛

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2213 题目大意:两个圆,并且知道两个圆的圆心和半径,求这两个圆共同的切线有多少条,若有无数条,输出-1,其他条 ...

  8. 2017福建省赛 FZU 2278 YYS 数学 大数

    Yinyangshi is a famous RPG game on mobile phones. Kim enjoys collecting cards in this game. Suppose ...

  9. ACM: FZU 2110 Star - 数学几何 - 水题

     FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Pr ...

随机推荐

  1. javascript-datatable错误提示

    datatables插件在使用的时候出现了如下错误提示**出现此错误的原因可能是你写的table中没有加上<thead>和<tbody>标签所致**     来自为知笔记(Wi ...

  2. 洛谷 P2700 逐个击破

    P2700 逐个击破 题目背景 三大战役的平津战场上,傅作义集团在以北平.天津为中心,东起唐山西至张家口的铁路线上摆起子一字长蛇阵,并企图在溃败时从海上南逃或向西逃窜.为了就地歼敌不让其逃走,毛主席制 ...

  3. WPF中多线程统计拆箱装箱和泛型的运行效率

    WPF中多线程统计拆箱装箱和泛型的执行效率.使用的知识点有泛型.多线程.托付.从样例中能够看到使用泛型的效率至少提升2倍 MainWindow.xaml <Window x:Class=&quo ...

  4. yolo环境配置

    主要配置参考官网https://pjreddie.com/darknet/yolo/ 为了能够可视化,另安装cuda+opencv cuda版本为9.0 opencv版本为3.1.0 先安装cuda再 ...

  5. hdoj--1260--Tickets(简单dp)

    Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  6. [Swift]数组(Array)最强解析

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  7. Android 度量单位

    单位 注释 px(像素) 每个像素对应手机上的一个点,在不同设备上1px表示的长度不一定相同 screen size(屏幕尺寸) 指手机对角线的长度,如4.7英寸 resolution(分辨率) 指屏 ...

  8. 51nod 2020 排序相减(暴力解法)

    题目: 代码: #include <bits\stdc++.h> using namespace std; int trim(int x){ ]; ;i < ; i++){ a[i] ...

  9. 用js将CheckBox的值存入数据库和将数据库字符串的值转为数组选中CheckBox

    Index @{ ViewBag.Title = "测试"; } <script src="~/Scripts/jquery-1.10.2.js"> ...

  10. 「JavaSE 重新出发」02. 数据类型与运算符

    「TOC」 Java 程序基本要求 Java 数据类型 基本数据类型 复合数据类型 运算符 逻辑运算符 位运算符 运算符优先级 Java 程序基本要求 public class : 一个 Java 文 ...