Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define RES_0 "ALIVE AND KICKING"
- #define RES_1 "DEAD AND ROTTING"
- int main(void)
- {
- int t, l, d, s, c;
- int i, j;
- int curr;
- int *res, k = 0;
- scanf("%d", &t);
- res = (int *) malloc(t * sizeof(int));
- if (!res)
- exit(EXIT_FAILURE);
- for (i = 0; i < t; i++)
- {
- scanf("%d %d %d %d", &l, &d, &s, &c);
- curr = s;
- for (j = 1; j < d; j++) // starting from day-2
- curr = curr + curr * c;
- if (curr >= l)
- res[k++] = 0;
- else
- res[k++] = 1;
- }
- for (i = 0; i < t; i++)
- printf("%s\n", res[i] ? RES_1 : RES_0);
- return 0;
- }
Add Comment
Please, Sign In to add comment