fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6. double a, b, i, j, dx;
  7. scanf("%lf %lf %lf %lf %lf", &a, &b, &i, &j, &dx);
  8.  
  9. double ans = 0.0;
  10. double le = i;
  11.  
  12.  
  13. while (le < j) {
  14. double width = dx;
  15. if (le + dx > j) {
  16. width = j - le;
  17. }
  18. ans += (a * sin(le) + b * cos(le)) * width;
  19. le += dx;
  20. }
  21.  
  22.  
  23. printf("%.2f\n", ans);
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5312KB
stdin
0.0 1.0 0.0 3.14159 0.01
stdout
0.01