fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int t;
  6. scanf("%d", &t);
  7.  
  8. while (t--) {
  9. double X1, X2, Y, h;
  10. scanf("%lf %lf %lf", &X1, &X2, &Y);
  11. scanf("%lf", &h);
  12.  
  13. double x_mid = (X1 + X2) / 2.0;
  14. double a = Y / ((x_mid - X1) * (x_mid - X2));
  15. double left = X1 < X2 ? X1 : X2;
  16. double right = X1 > X2 ? X1 : X2;
  17.  
  18. double base_area = fabs(a) * pow(right - left, 3) / 6.0;
  19. double volume = (1.0 / 3.0) * base_area * h;
  20.  
  21. printf("%.4f\n", volume);
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty