fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4. using namespace std;
  5. int main()
  6. {
  7. int n;
  8. scanf("%d",&n);
  9. double a,b,c,ha,hb,hc,ma,cosa,r,l,res,area;
  10. for (int i=0;i<n;i++)
  11. {
  12. scanf("%lf %lf %lf %lf",&a,&ha,&hb,&hc);
  13. //printf("%lf %lf %lf %lf\n",a,ha,hb,hc);
  14. ha*=3;hb*=3;hc*=3;
  15. c=(a*ha)/hc; b=(a*ha)/hb;
  16. ma=sqrt(0.5*b*b+0.5*c*c-0.25*a*a);
  17. cosa=ha/ma;
  18. r=(2*ma)/3;
  19. l=b*(b-sqrt(a*a-hb*hb))/ha;
  20. // printf("%lf\n",l*l+r*r-2*cosa*l*r);
  21. res=l*l+r*r-2*cosa*l*r;
  22. if (res<0) res=0; else res=sqrt(res);
  23. area=a*ha/2;
  24. printf("%.3lf %.3lf\n",area,res);
  25. }
  26. //system("PAUSE");
  27. return 0;
  28. }
  29.  
stdin
2
3.0 0.8660254038 0.8660254038 0.8660254038
657.8256599140 151.6154399062 213.5392629932 139.4878846649
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:12: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
3.897 0.000
149604.790 150.275