码迷,mamicode.com
首页 > 其他好文 > 详细

UVA11731 - Ex-circles

时间:2014-09-10 19:32:00      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   os   ar   strong   for   

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


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


我的做法:


直接列方程组解……


我的代码:

#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

 

bubuko.com,布布扣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

UVA11731 - Ex-circles

标签:des   style   blog   http   io   os   ar   strong   for   

原文地址:http://blog.csdn.net/stl112514/article/details/39184855

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!