Plabon_dutta

Uva 1709

Mar 1st, 2021 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include<math.h>
  4.  
  5. int main() {
  6.     int p, a, b, c, d, n;
  7.     while (scanf("%d %d %d %d %d", &p, &a, &b, &c, &d) == 5) {
  8.         scanf("%d", &n);
  9.         double max_decline = 0;
  10.         double max = p * (sin((a + b)) + cos((c + d)) + 2);
  11.         for (int k = 2; k <= n; k++) {
  12.             double curr = p * (sin((a * k + b)) + cos((c * k + d)) + 2);
  13.                 if (max > curr) {
  14.                     if(max_decline< max - curr){
  15.                         max_decline=max-curr;
  16.                     }
  17.                 } else {
  18.                     max = curr;
  19.                 }
  20.         }
  21.         printf("%.8lf\n", max_decline);
  22.     }
  23.     return 0;
  24. }
  25.  
Add Comment
Please, Sign In to add comment