1378 The Falling Circle

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
#define DB double

using namespace std;
const DB PI = acos(-1.0);
struct cycle{
    DB x,y,r;
    void get(){scanf("%lf%lf%lf",&x,&y,&r);}
};
DB dist(cycle a,cycle b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","r",stdout);
    #endif
    cycle a,c,b;
    int cas,T=1;scanf("%d",&cas);
    while(cas--)
    {
        a.get();b.get();c.get();
        if(a.y-a.r>b.y-b.r) swap(a,b);
        DB d = dist(a,b);
        DB alph = atan((b.y-a.y)/fabs(b.x-a.x))-asin((b.r-a.r)/d);
        DB low = a.y - a.r/cos(alph);
        DB d1 = c.y - low-fabs(c.x-a.x)*tan(alph)-c.r/cos(alph);
        DB d2;
        if(fabs(a.y-a.r-b.y+b.r)<0.1)
        {
            d2 = 0;
        }else
        {
            DB l1 = sqrt((a.r+c.r)*(a.r+c.r)-(a.r-c.r)*(a.r-c.r));
            d2 = fabs(a.x-c.x)/cos(alph)+c.r*tan(alph)-a.r*tan(alph) - l1;
            d2 = d2/c.r/2/PI;
        }
        printf("Case %d: %.10lf\n",T++,d1+d2);
    }
    return 0;
}

时间: 2024-10-17 13:29:04

1378 The Falling Circle的相关文章

启动hive报错[ERROR] Terminal initialization failed; falling back to unsupported

启动hive时报如下的错误[ERROR] Terminal initialization failed; falling back to unsupported 解决办法:进入到hadoop安装目录下的share/hadoop/yarn下删除 jline的jar文件.再启动hive即可 版权声明:本文为博主原创文章,未经博主允许不得转载.

657. Judge Route Circle 判断线路成圆

Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place. The move sequence is represented by a string. And each move is represent by a characte

【数据结构】The Falling Leaves(6-10)

[UVA699]The Falling Leaves 算法入门经典第6章例题6-10(P159) 题目大意:有一颗二叉树,求水平位置的和. 试题分析:乱搞就可以过,将树根节点的pos记为0,向左-1,向右+1,统计答案即可. #include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<queue> #include<stack> #in

SVG圆形&lt;circle&gt; 标签

1 <?xml version="1.0" standalone="no"?> 2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 3 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 4 5 <svg width="100%" height="100%" v

hzau 1208 Color Circle(dfs)

1208: Color Circle Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 289  Solved: 85[Submit][Status][Web Board] Description There are colorful flowers in the parterre in front of the door of college and form many beautiful patterns. Now, you want to fi

java定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个findArea()方法返回圆的面积

需求如下:(1)定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个findArea()方法返回圆的面积. (2)定义一个类PassObject,在类中定义一个方法printAreas(),该方法的定义如下: public void printAreas(Cirlce c, int times) 在printAreas方法中打印输出1到time之间的每个整数半径值,以及对应的面积.例如,times为5,则输出半径1,2,3,4,5,以及对应的圆面积. 在main方法

HDU 5343 MZL&#39;s Circle Zhou

MZL's Circle Zhou Time Limit: 1000ms Memory Limit: 131072KB This problem will be judged on HDU. Original ID: 534364-bit integer IO format: %I64d      Java class name: Main MZL's Circle Zhou is good at solving some counting problems. One day, he comes

UVa 699.The Falling Leaves【7月23】

The Falling Leaves Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating under the trees. If the same thing happened to binary trees, how lar

ZOJ 3321 Circle(并查集啊)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3731 Your task is so easy. I will give you an undirected graph, and you just need to tell me whether the graph is just a circle. A cycle is three or more nodes V1, V2, V3, ...Vk, such th