razvanth21

Untitled

May 11th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define RES_0 "ALIVE AND KICKING"
  5. #define RES_1 "DEAD AND ROTTING"
  6.  
  7. int main(void)
  8. {
  9.     int t, l, d, s, c;
  10.     int i, j;
  11.     int curr;
  12.     int *res, k = 0;
  13.  
  14.     scanf("%d", &t);
  15.     res = (int *) malloc(t * sizeof(int));
  16.  
  17.     if (!res)
  18.         exit(EXIT_FAILURE);
  19.  
  20.     for (i = 0; i < t; i++)
  21.     {
  22.         scanf("%d %d %d %d", &l, &d, &s, &c);
  23.  
  24.         curr = s;
  25.  
  26.         for (j = 1; j < d; j++) // starting from day-2
  27.             curr = curr + curr * c;
  28.        
  29.         if (curr >= l)
  30.             res[k++] = 0;
  31.  
  32.         else
  33.             res[k++] = 1;
  34.     }
  35.  
  36.     for (i = 0; i < t; i++)
  37.         printf("%s\n", res[i] ? RES_1 : RES_0);
  38.    
  39.     return 0;
  40. }
Add Comment
Please, Sign In to add comment