In-circles Again(简单几何)

In-circles Again

Time Limit: 1000ms

Memory Limit: 65536KB

64-bit integer IO format: %lld      Java class name:
Main

Submit
Status PID: 4272

In the figure below you can see triangle ABC and its in-circle (Circle that touches all the sides of a triangle internally). The radius of this in circle is r. Three other circles are drawn. Each of them touches
two sides of this triangle and the in circle of ABC. The radiuses of these circles are r1, r2 and r3.

Given the values of r, r1, r2 and r3 you will have to find the area of triangle ABC.

Input

The input file can contain up to 1000 lines of inputs. Each line contains four positive floating-point numbers which denotes the values of r, r1, r2 and r3 respectively.

Input is terminated by a line containing four negative integers.

Output

For each line of input produce one line of output. This line contains serial of output followed by a floating-point number which denotes the area of triangle ABC. This floating-point number may have two digits after the decimal point. You can assume that
for the given values of r, r1, r2 and r3 it will always be possible to construct a triangle ABC. If required you can assume that pi = 3.141592653589793 and also use double precision floating-point numbers for floating-point calculations. You can assume that
there will be no such input for which small precision errors will cause difference in printed output. Look at the output for sample input for details.

Sample Input

49.1958415692 5.3025839959 20.7869367050 31.8019699761
186.6830516757 71.9474500429 84.8796672233 37.6219288070
-1 -1 -1 -1

Sample Output

Case 1: 18237.14
Case 2: 195777.32

思路:
#include<bits/stdc++.h>
using namespace std;

double r[5];

double fun(double r1,double r2)
{
    return ((r1+r2)*(r1+r2)-(r1-r2)*(r1-r2));
}
bool cmp(double p1,double p2)
{
    return p1>p2;
}
int main()
{
    int d=1;
    while (~scanf("%lf%lf%lf%lf",&r[0],&r[1],&r[2],&r[3]) && r[0]!=-1)
    {
        sort(r,r+4,cmp);
//            for (int i=0;i<4;i++)
//                printf("%lf ",r[i]);
//                printf("\n");
        double a1 = sqrt(fun(r[0],r[1])); double x1 = (a1*r[1]*1.0)/(r[0]-r[1]);
        double a2 = sqrt(fun(r[0],r[2])); double x2 = (a2*r[2]*1.0)/(r[0]-r[2]);
        double a3 = sqrt(fun(r[0],r[3]));  double x3 = (a3*r[3]*1.0)/(r[0]-r[3]);
        double aa1=(a1+x1)+(a2+x2),aa2=(a2+x2)+(a3+x3),aa3=(a1+x1)+(a3+x3);
        double q=(aa1+aa2+aa3)/2.0;
        double s= sqrt(q*(q-aa1)*(q-aa2)*(q-aa3));

        printf("Case %d: %.2lf\n",d++,s);
    }
    return 0;
}
时间: 2024-10-06 01:58:20

In-circles Again(简单几何)的相关文章

Python下opencv使用笔记(二)(简单几何图像绘制)

简单几何图像一般包括点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义.图像的一个像素点有1或者3个值,对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值,他们表现出不同的颜色. 那么有了点才能组成各种多边形. (一)首先绘制直线 函数为:cv2.line(img,Point pt1,Point pt2,color,thickness=1,line_type=8 shift=0) 有值的代表有默认值,不用给也行.可以看到这个函数主要接受参数为两个点的坐标,线的颜色

POJ 1473 There&#39;s Treasure Everywhere!(简单几何)

There's Treasure Everywhere! 博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40865611 题目大意: 给你一个字符串,里面有许多的操作,前面的数字是移动的距离,后面的英文表示移动的方向,问最后从远点出发的一个点回落在什么地方以及距离出发点的距离是多少. 解题思路: 题目本身并不是很难,也没有什么坑点,没什么好说的,字符串处理的时候细心一点就行. PS:每组后面需要加一个回车,因为这个PE了一次

简单几何 UVA 11178 Morley&#39;s Theorem

题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /************************************************ * Author :Running_Time * Created Time :2015/10/21 星期三 15:56:27 * File Name :UVA_11178.cpp ************************************************/ #include

HDU 4793 Collision + HDU 4798 Skycity 简单几何

HDU 4793 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4793 题意:给一个以(0,0)为圆心半径为R的圆形区域,中间放着一个(0,0)为圆心半径为Rm的圆盘,在坐标(x,y)处(严格在圆形区域外)放着一枚半径为r的硬币,运动方向和速度为(vx,vy),在运动中碰到圆盘时,会按碰撞问题反弹(圆盘是固定不动的),问硬币会在圆形区域里呆多长时间(硬币只要有一点点在圆形区域里就记为硬币在圆形区域内). 思路:首先先计算出硬币在移动过程中如果不与圆盘

hdu5365 简单几何问题

http://acm.hdu.edu.cn/showproblem.php?pid=5365 Problem Description AFA is a girl who like runing.Today,he download an app about runing .The app can record the trace of her runing.AFA will start runing in the park.There are many chairs in the park,and

The Doors 最短路 + 简单几何

The Doors 题目抽象:给你一些点,和一些阻碍连边的线段.问原点到终点最短的几何距离. 分析:预处理见图之后,跑最短路. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 using namespace std; 6 const int INF = 0X5FFFFFFF; 7 const int MS = 1005; 8 const i

CodeForces 703C Chris and Road (简单几何)

题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标.并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点.现在要求人不能碰到汽车,人可以自己调节速度.问人到达马路对面的最小时间是多少? 析:这个题是一个简单的分类讨论,很明显只有两种情况,第一种,直接到达w,不会被车撞到,答案就是w/u, 第二种是切着车过去,或者是等车过去再过去,只要枚举车的每个顶点,找到最后通过y轴的点就好,或者根本不会与车相切. 代码如下: #pragma comment(l

osg for android (一) 简单几何物体的加载与显示

1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一):新版NDK环境搭建(免Cygwin,超级快)  (2).osg for android的编译,参考 osg for android学习之一:windows下编译(亲测通过) 建议编译OpenGL ES2版本. 2.然后加载OSG自带的Example:osgAndroidExampleGLES2 (

简单几何(线段相交) POJ 2653 Pick-up sticks

题目传送门 题意:就是小时候玩的一种游戏,问有多少线段盖在最上面 分析:简单线段相交,队列维护当前最上的线段 /************************************************ * Author :Running_Time * Created Time :2015/10/26 星期一 15:37:36 * File Name :POJ_2653.cpp ************************************************/ #inclu