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. 创业笔记-Node.js入门之阻塞与非阻塞

    阻塞与非阻塞 正如此前所提到的,当在请求处理程序中包括非阻塞操作时就会出问题.但是,在说这之前,我们先来看看什么是阻塞操作. 我不想去解释“阻塞”和“非阻塞”的具体含义,我们直接来看,当在请求处理程序 ...

  2. Tarjan缩点【模板】

    #include <algorithm> #include <cstdio> #include <map> using namespace std; ); map& ...

  3. [CSS3] Create Dynamic Styles with CSS Variables

    In this lesson we are going to use CSS variables to keep our application's colors consistent. This i ...

  4. html页面的简单对话框(alert, confirm, prompt)

    html页面简单的三种对话框例如以下: 1.alert(),最简单的提示框: alert("你好!"); 2.confirm(),有确认和取消两个button: if(confir ...

  5. error[No partition metadata for topic test-1 due to kafka.common.LeaderNotAvailableException]

    http://stackoverflow.com/questions/23228222/running-into-leadernotavailableexception-when-using-kafk ...

  6. JAVA设计模式之【建造者模式】

    建造者模式 建造者模式为客户端返回的不是一个简单的产品,而是一个由多个部件组成的复杂产品 角色 Builder抽象建造者 buildPartX getResult ConcreteBuilder具体建 ...

  7. Oracle GoldenGate

    Oracle GoldenGate实现数据库同步 前言:最近刚好在弄数据库同步,网上查了些资料再加上自己整理了一些,做个分享! 一.GoldenGate的安装 官方文档: Oracle®GoldenG ...

  8. 唯品会API网关设计与实践--转

    原文地址:https://609518.kuaizhan.com/86/70/p4108366952248f 刘璟宇Leo 唯品会资深研发工程师,在大型高性能分布式系统设计和开发方面有丰富的经验.目前 ...

  9. lucene简单使用demo

    测试结构目录: 1.索引库.分词器 Configuration.java package com.test.www.web.lucene; import java.io.File; import or ...

  10. Gradle学习总结

    Gradle学习系列 (1). Gradle快速入门 (2). 创建Task的多种方法 (3). 读懂Gradle语法 (4). 增量式构建 (5). 自定义Property (6). 使用java ...