UVA11731 - Ex-circles

给出一个三角形,把三角形的三条边无限延长,然后做四个圆,最后……

也不知道怎么说,反正就是求阴影部分的面积和形成的三角形的面积

我的做法:

直接列方程组解……

我的代码:

#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
struct dot
{
	double x,y;
	dot(){}
	dot(double a,double b)
	{
		x=a;
		y=b;
	}
	friend double operator *(dot a,dot b)
	{
		return a.x*b.y-b.x*a.y;
	}
	friend dot operator -(dot a,dot b)
	{
		return dot(a.x-b.x,a.y-b.y);
	}
};
struct fun
{
	double a,b,c;
	fun(){}
	fun(double x,double y,double z)
	{
		a=x;
		b=y;
		c=z;
	}
};
dot sf(fun a,fun b)
{
	double c,d,e;
	c=dot(a.a,b.a)*dot(a.b,b.b);
	d=dot(a.c,b.c)*dot(a.b,b.b);
	e=dot(a.a,b.a)*dot(a.c,b.c);
	return dot(d/c,e/c);
}
double dis(dot a,dot b)
{
	return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
double cang(double a,double b,double c)
{
	return acos((pow(b,2)+pow(c,2)-pow(a,2))/2/b/c);
}
int main()
{
	int i,j,k,T=0;
	dot d,e[4],box[3];
	double a,b,c,A,B,s,smax,side[3],ans;
	while(cin>>a>>b>>c)
	{
		if(a==0&&b==0&&c==0)
			break;
		d.x=(a*a-b*b+c*c)/2/a;
		d.y=sqrt(c*c-d.x*d.x);
		A=sqrt(pow(d.x,2)+pow(d.y,2));
		B=sqrt(pow(d.y,2)+pow(a-d.x,2));
		e[0]=sf(fun(d.y,-(d.x+A),0),fun(d.y,a-d.x+B,a*d.y));
		e[1]=sf(fun(d.y,-(d.x+A),0),fun(d.y,a-d.x-B,a*d.y));
		e[2]=sf(fun(d.y,-(d.x-A),0),fun(d.y,a-d.x+B,a*d.y));
		e[3]=sf(fun(d.y,-(d.x-A),0),fun(d.y,a-d.x-B,a*d.y));
		smax=0;
		for(i=0;i<2;i++)
			for(j=i+1;j<3;j++)
				for(k=j+1;k<4;k++)
				{
					s=fabs((e[j]-e[i])*(e[k]-e[i])/2);
					if(s>smax)
					{
						box[0]=e[i];
						box[1]=e[j];
						box[2]=e[k];
						smax=s;
					}
				}
		k=0;
		for(i=0;i<2;i++)
			for(j=i+1;j<3;j++)
				side[k++]=dis(box[i],box[j]);
		ans=pow(box[0].y,2)*cang(side[2],side[0],side[1]);
		ans+=pow(box[1].y,2)*cang(side[1],side[0],side[2]);
		ans+=pow(box[2].y,2)*cang(side[0],side[1],side[2]);
		ans/=2;
		printf("Case %d: %.2lf %.2lf\n",++T,smax,ans);
	}
}

Time limit: 1.000 seconds


I


Ex-circles

Input: Standard Input

Output: Standard Output

Inthe figure on the right you can see triangle ABC and its in-circle (Circle thattouches all the sides of a triangle internally) and three
ex-circles (Circles thattouch one side internally and other two sides externally). D, E and F arecenters of the ex-circles.

Given the length of the sides oftriangle ABC, you will have to find the area of triangle DEF and also the totalarea of the three grey shaded regions.

Input

The input file can contain up to6000 lines of inputs. Each line contains three positive integer numbers a, b, cwhich denotes the length of the sides of the triangle ABC. You can assume thatthese three sides can form a valid triangle (positive area) and none
of theside length is greater than 1000.

Input is terminated by a linecontaining three zeroes.

Output

For each lineof input produce one line of output. This line contains the serial of outputfollowed by two floating-point numbers. The first one denotes the area oftriangle DEF and second one denotes the total area of the three gray shadedregions. This floating-point
numbers should have two digits after the decimalpoint. You can assume that small precision errors will not cause difference inthe printed output.

 

Sample Input                             Output for SampleInput


3 4 5

10 11 12

0 0 0


Case 1: 30.00 21.62

Case 2: 211.37 144.73


ProblemSetter: Shahriar Manzoor, Special Thanks: Sohel Hafiz

时间: 2024-10-20 10:48:57

UVA11731 - Ex-circles的相关文章

CSU 1412 Line and Circles

原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1412 题目要求判断是否有一条直线可以穿过所有的圆. 做法:把所有圆心做一次凸包,然后判断这个凸包是否能通过一个宽度为2*R的通道. 做法和求凸包直径差不多,只是判断的时候把点到两个端点的距离换成点到直线的距离. #include <stdio.h> #include <string.h> #include <math.h> #include <stdli

计数方法,博弈论(扫描线,树形SG):HDU 5299 Circles Game

There are n circles on a infinitely large table.With every two circle, either one contains another or isolates from the other.They are never crossed nor tangent.Alice and Bob are playing a game concerning these circles.They take turn to play,Alice go

Calling Circles

Description: If you've seen television commercials for long-distance phone companies lately, you've noticed that many companies have been spending a lot of money trying to convince people that they provide the best service at the lowest cost. One com

SPOJ CIRU The area of the union of circles

You are given N circles and expected to calculate the area of the union of the circles ! Input The first line is one integer n indicates the number of the circles. (1 <= n <= 1000) Then follows n lines every line has three integers Xi Yi Ri indicate

codeforces 600D Area of Two Circles&#39; Intersection

分相离,内含,想交三种情况讨论一下. 主要是精度和数据范围的问题,首先数据用long double,能用整型判断就不要用浮点型. 题目中所给的坐标,半径是整型的,出现卡浮点判断的情况还是比较少的. 最后算三角型面积的时候不要用海伦公式,有四个连乘很容易爆数据范围损失精度,即使拆开两两乘也要考虑符号 (取对数也是比较好的办法).(不知道sqrt和cos,sin的精度如何比较 #include<bits/stdc++.h> using namespace std; typedef long dou

11.3.4 例题11-4 UVA 247 Calling Circles (有向图的传递闭包)

题目大意: 给你n个人,m条边,a->b,b->a,才能说这两个人是联通的.问现在有多少个联通圈.输出每个联通圈.n<=25 解题思路: 直接建图,用有向图的闭包传递特性来处理每个人之间的联通关系.然后dfs一次,遍历邻接矩阵中与某个点相连的几个点,边遍历, 边打印输出. 代码: # include<cstdio> # include<iostream> # include<map> # include<cstring> # include

POJ 3808 Malfatti Circles(计算几何)

Malfatti Circles Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 250   Accepted: 125   Special Judge Description The con?guration of three circles packed inside a triangle such that each circle is tangent to the other two circles and to

[LeetCode] Friend Circles 朋友圈

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a fri

--uva247(calling circles)强联通与floyd-warshell

图论题:一开始我是用tarjan算法做的,wrong answer 了很多次,然后又用了floyd-warshell算法,也wa了 最后找了题解,原来最后的dataset后面不是组数,是样例的编号,题根本就没说,让人怎么理解... tarjan #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<map> #include<alg

HDOJ 5299 Circles Game 圆嵌套+树上SG

将所有的圆化成树,然后就可以转化成树上的删边博弈问题.... Circles Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 881    Accepted Submission(s): 255 Problem Description There are n circles on a infinitely large tabl