375

Solution:

radius of an inscribed circle of a  triangle

r = (2 * area of triangle) /perimeter of triangle;

#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    int t;
    double B,H,R,d,a,b,r,h,c,l;
    double x;
    cin>>t;

    while(t--)
    {
       cin>>B>>H;
       l=H;
       h=H;
       a=(B/2)*(B/2);
       c=H*H;
       d=0;
       r=(B*H)/(B+2*sqrt(a+c));
       R=r;
       while(r>=0.000001)
       {
          h-=2*r;
          d+=2*r;
          r=h/H*R;
       }

       printf("%13lf\n",d*M_PI);
       if(t)
       cout<<"\n";
    }

    return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *