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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值