UVA375等腰三角行无限内切圆面积

本文介绍了一种计算由一系列内切圆组成的图形总面积的算法。通过不断更新三角形的底边和高来求得每个内切圆的半径,并累加其面积,直至内切圆直径接近于零。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚开始自己做的时候以为每个内切圆的直径连起来刚好等于高,那个精度并没有什么用,显然想当然了,

而是每个内切圆都相当于一个新的三角形,重新求三角形的底边和高,利用最开始的底和高求出tan@和

tan@/2,然后逐层递归即可。

#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
#include<memory>
#include<climits>
#include<cstdlib>
using namespace std;
#define LL long long
#define INT (1LL<<62);
const double eps=1e-6;
const double pi=4*atan(1.0);
int dcmp(double x)
{
    return fabs(x)<eps?0:(x>0?1:-1);
}
/*struct point
{
    double x,y;
    point() {};
    point(double x,double y):x(x),y(y){};
    point operator + (point b)
    {
        return point(x+b.x,y+b.y);
    }
    point operator - (point b)
    {
        return point(x-b.x,y-b.y);
    }
    point operator / (double b)
    {
        return point(x/b,y/b);
    }
    point operator * (double b)
    {
        return point(x*b,y*b);
    }

};
double dot(point a,point b)
{
    return a.x*b.x+a.y*b.y;
}
double length(point a)
{
    return sqrt(dot(a,a));
}
double dd(point a,point b)
{
  return sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
}
point zx(point a)
{
   double d=length(a);
   return point(-a.y/d,a.x/d);
}*/
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        double b,h;
        cin>>b>>h;
        double r;
        double sum=0;
        while(1)
        {
            double l=atan(h/(b/2));
            r=tan(l/2)*b/2;
            if(r<0.000001) break;
            sum=sum+2*pi*r;
            b=b*(h-2*r)/h;
            h=h-2*r;
        }
        printf("%13.6f\n",sum);
        if(t) cout<<endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值