Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

给出公式! 不需要解析几何!

Posted by 810974380 at 2009-08-03 15:46:30 on Problem 2242
先求出3边长,由海伦公式得出面积
S=sqrt(p*(p-a)*(p-b)*(p-c))    p=(a+b+c)/2;
由三角形面积公式S=1/2*a*b*sin(C)
和正弦定理a/sin(A)=b/sin(B)=c/sin(C)=直径
可得直径=a*b*c/2/S;   (a,b,c为三边长)
所以周长即为直径*PI

完毕!

下面是A过的代码!不嫌麻烦的可以看看!!!

#include<stdio.h>
#include<math.h>
#define PI 3.141592653589793
double w(double a,double b,double c,double d) //求边长
{ double x;
 x=sqrt((a-c)*(a-c)+(b-d)*(b-d));
 return x;
}
double g(double o,double p,double q) //求三角形面积:海伦公式
{ double m=(o+p+q)/2;
  m=sqrt(m*(m-o)*(m-p)*(m-q));
  return m;
}
double h(double s,double u,double v,double w) //求直径
{double y;
 y=2*s/u/v;
 y=w/y;
 return y;
}
int main()
{double a,b,c,d,e,f,i,j,k,l;
while((scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f))!=EOF){
     i=w(a,b,c,d);
	 j=w(a,b,e,f);
	 k=w(c,d,e,f);
	 l=g(i,j,k);
   l=h(l,i,j,k);
   printf("%.2lf\n",PI*l);
}
return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator