UVA Solution 375 - Inscribed Circles and Isosceles Triangles - Solution in C, C++ | Volume 3 - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Friday, May 5, 2017

UVA Solution 375 - Inscribed Circles and Isosceles Triangles - Solution in C, C++ | Volume 3

UVA Solution 375 - Inscribed Circles and Isosceles Triangles - Solution in C, C++ | Volume 3


UVA Online Judge Solution 375 - Inscribed Circles and Isosceles Triangles | Volume 3
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=311

Problem Name: 375 - Inscribed Circles and Isosceles Triangles
Problem Number : UVA - 375 - Inscribed Circles and Isosceles Triangles
Online Judge : UVA Online Judge Solution
Volume: 3
Solution Language : C, C plus plus

UVA Solution 375 - Inscribed Circles and Isosceles Triangles - Solution in C, C++ | Volume 3

UVA Solution 375 - Inscribed Circles and Isosceles Triangles Code in C, CPP:


#include <stdio.h>
#include <math.h>
int main() {
    int t;
    double pi = acos(-1);
    scanf("%d", &t);
    while(t--) {
        double B, H, C = 0;
        scanf("%lf %lf", &B, &H);
        double area = B*H/2;
        double L = sqrt(H*H + B*B/4)*2 + B;
        double R = area*2 / L;
        while(R >= 0.000001) {
            C += 2*pi*R;
            double tmp = H;
            H -= 2*R;
            R *= H/tmp;
        }
        printf("%13.6lf\n", C);
        if(t)
            puts("");
    }
    return 0;
}

No comments:

Post a Comment