Paste will expire never.
- // Меньшиков. Тренировка 15.
- // 15B. Площадь треугольника [tria-abm]
- // ibelyaev: 14Jan2011
- #include <iostream>
- #include <cstdio>
- #include <cmath>
- using namespace std;
- const double eps = 1e-6;
- double h,m,b;
- void input()
- {
- cin>>h>>b>>m;
- }
- double getB(double x) {
- double d = sqrt(m*m - h*h);
- double l = sqrt(h*h + (d+x)*(d+x));
- double r = sqrt(h*h + (d-x)*(d-x));
- double bpx = d - x + (2*r*x) / (l+r);
- return sqrt(bpx*bpx + h*h);
- }
- void solve()
- {
- if (h>b) swap(h,b);
- if (b>m) swap(b,m);
- if (h>b) swap(h,b);
- if (h == b && b == m)
- cout<<0;
- else if(h==b || b==m)
- cout<<-1;
- else {
- double l = 0, r = 2e9;
- while (l + eps < r) {
- double m = (l + r) / 2;
- if (getB(m) > b)
- l = m;
- else
- r = m;
- }
- printf("%0.5f",l*h);
- }
- }
- int main()
- {
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- input();
- solve();
- return 0;
- }
Editing is locked.