Uva375 内接圆和等腰三角形

几何375 内接圆和等腰三角形

题目:

Circumferences周长inscribedcircles内接圆

Given two real numbers

B the width of the base of an isoscelestriangle等腰三角形 in inches

H the altitude高 of the sameisosceles triangle in inches

Compute to six significant decimal places小数位数

C the sum of the circumferences周长 of aseries of inscribed circles内接圆 stacked one on top of another from the base to the peak; such thatthe lowest inscribed circle is tangent相切 to the base and the two sides

and the next higher inscribed circle istangent to the lowestinscribed circle and the two sides, etc. In order to keep the timerequired to compute the result within reasonable bounds, you may limit theradius半径 of the smallest inscribed circle in the stack to a single precision精度 floatingpoint value of 0.000001.

For those whose geometry and trigonometry几何和三角 are abit rusty, the center of an inscribed circle is at the point of intersection交点 of thethree angular bisectors角等分线(中线).

 

The input begins with a single positiveinteger on a line by itself indicating the number of the cases following, eachof them as described below.

This line is followed by a blank line, andthere is also a blank line between two consecutive inputs.

The input will be a single line of textcontaining two positive single precision real numbers (B H) separated byspaces.

Output For each test case, the output mustfollow the description below. The outputs of two consecutive cases will beseparated by a blank line. The output should be a single real number withtwelve significant digits, six of which follow the decimal point. The decimalpoint must be printed in column 7.


角平分线是内接圆,中垂线是外接圆(等腰三角形的中线垂直底边)

求内接圆半径:过圆心作三条线段分别与三角形三条边abc垂直,这时三角形面积可以用三个小三角形来求,
a*r/2+b*r/2+c*r/2=(a+b+c)*r/2=S

所以r=2S/(a+b+c)





A^2=(1/2*b)^2+h^2勾股定理求斜边长

r=bh/(b+2a)

C=2*PAI*r

H1=h-2*r

B1= b*h1/h B1/B=h1/h三角形相似比算下一代底边长

debug过程

输出格式问题:%n.mf  即输出总共占n位其中有m位小数

//0.263451
#include<stdio.h>
#include<math.h>
#define PAI 4.0*atan(1.0)
//#define LOCAL
int main(){
	#ifdef LOCAL
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
	#endif
	int n,i,flag=1;//样例组数,首行标志 
	double b,h,h1,sum=0,a,r; 
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf",&b,&h);
		sum=0;
		while(1){
			a=sqrt(0.25*b*b+h*h);
			r=b*h/(b+2*a);
			if(r<0.000001)break;
			sum+=2*PAI*r;
			
			h1=h-2*r;
			b=b*h1/h;
			h=h1;
//			printf("%f\n",sum);
		}
		if(flag) flag=0;
		else printf("\n");
		printf("%13.6lf\n",sum);		
	}
	return 0;
}
也是udebug完全一致,提交后WA。

改变PAI的定义为atan就AC了


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值