圆啊圆

来源:互联网 发布:mac virtualbox装win7 编辑:程序博客网 时间:2024/06/10 01:30

圆啊圆
Time Limit: 1000msMemory Limit: 65536KB 64-bit integer IO format: %lld Java class name: Main
Prev Submit Status Statistics Next
Type:
None

Tag it!
给出A圆的圆心坐标和其半径,给出B圆上的三点,判断这两个圆是否相切。PS: 运算过程中小数点后6位忽略不计。

Input
输入包含多组数据,对于每组数据:

第一行包含3个数,-1000<=X,Y<=1000,0

#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<algorithm>#include<stack>#include<queue>#include<cctype>#include<functional>using namespace std;#define swap(a,b) {long long c=a;a=b;b=c;}const int MAX = 999999;const double Eps = 1e-6;const double PI = acos(-1.0);int gcd(int x, int y){    return x%y == 0 ? y : gcd(y, x%y);}int main(){    double x1, x2, y1, y2, x, y, r, x3, y3;    double xa, ya, ra, xb, yb, rb;    while (cin >> xa >> ya >> ra)    {        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;        double k1, k2, v, u;        u = (x1*x1 - x2*x2 + y1*y1 - y2*y2) / (2 * x1 - 2 * x2);        k1 = (y1 - y2) / (x1 - x2);        v = (x1*x1 - x3*x3 + y1*y1 - y3*y3) / (2 * x1 - 2 * x3);        k2 = (y1 - y3) / (x1 - x3);        yb = (u - v) / (k1 - k2);        xb = v - (u - v)*k2 / (k1 - k2);        rb = sqrt((xb - x1)*(xb - x1) + (yb - y1)*(yb - y1));        double dd = sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb));        double t1 = ra + rb;        double t2 = fabs(ra - rb);        // if (fabs(dd - t1) <= 1e-6 || (dd - t2) <= 1e-6)//wa         if(fabs(dd-t1)<=1e-6||fabs(dd-t2)<=1e-6)//ac            printf("Yes\n");        else printf("No\n");    }    return 0;}