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. Bing地图切片原理

    Bing地图切片系统 Bing地图提供了一个可以直接平移和缩放的世界地图.为了让地图操作更加平滑和及时响应,我们选择提前渲染地图不同层级的细节,并把每个层级的地图切割成为瓦片以便快速的还原展示.这篇文 ...

  2. Raspberry PI 系列 —— 裸机点亮LED灯

    Raspberry PI 系列 -- 裸机点亮LED灯 背景 近期刚买了Raspberry PI B+,配置执行了官方提供的Raspbian系统,折腾了一周Linux系统,感觉没啥意思,于是就试着想了 ...

  3. Android自己定义组件系列【4】——自己定义ViewGroup实现双側滑动

    在上一篇文章<Android自己定义组件系列[3]--自己定义ViewGroup实现側滑>中实现了仿Facebook和人人网的側滑效果,这一篇我们将接着上一篇来实现双面滑动的效果. 1.布 ...

  4. Android学习JNI,使用JNI实现字符串加密

    本节学习使用C语言加密字符串,大家都知道使用JAVA实现的加密都能够反编译的,而使用C写的加密是非常难被反编译的.所以我们使用JNI学习怎样使用C实现对字符串的加密. 首先:我们实现一个界面 布局文件 ...

  5. 黑马day15 文件上传&amp;apche的工具包

    1.肯定要导入apche的jar包 2.要使用的类的介绍.. 2.1DiskFileItemFactory  public DiskFileItemFactory(int sizeThreshold, ...

  6. [雅礼NOIP2018集训 day1]

    现在才来填坑,之后还要陆续补其他几天的,可能前几天真的太颓了 T1: 题目大意:给定一个长度为n的序列,m次询问每次询问给出l,r,询问区间l到r的元素在模k意义下的最大值 数据范围当然是你暴力写不过 ...

  7. calender怎么获取每周的周日(给每周的周日特定时间点设置定时)

    获取每周的周日 //如果是周日,特殊处理.老外的周日-周六为一周 calendarTemp.add(Calendar.WEEK_OF_MONTH,1); calendarTemp.set(Calend ...

  8. jsp表单验证格式

  9. php报错权限设置

    <?php //禁用错误报告 error_reporting(0); //报告运行时错误 error_reporting(E_ERROR | E_WARNING | E_PARSE); //报告 ...

  10. 数组的常用方法 Array;

    数组: 1,arr.join();//返回默认由逗号隔开的一个字符串,传参则返回所传参数隔开的一个字符串; 2,arr.push();//往数组最后添加数据,返回新的数组的length,这个方法将改变 ...