**QUESTION**

Foo was not amongst the most brilliant students of his class. So, he has some pending exams to clear. As the exams are approaching, this time he vowed to pass in all of them. This will only happen if he is not under stress. Foo’s stress can be calculated using a simple function called Foo_function which depends upon the time for which Foo studies continuously .\n\nFoo_funtion is defined as follows:\n\nF(t)=A(t^3)+B(t^2)+C*(t)+D, F(t)<=10^18\n\nwhere A,B,C,D belong to the set of prime numbers. t is the time in minutes for which foo studies continuously.\n\nAs foo is not very good at solving cubic equations, he seeks your help to find out the maximum number of minutes for which he can study continuously without taking stress. Help him find t such that F(t+1) > K, and F(t) <= K, where K is the maximum stress Foo can bear.\n\nInput:\n\nEach test case consists of a single line containing 5 space seperated positive numbers a, b, c, d, K.\n\nOutput:\n\nFor each test case, output a single integer t denoting the maximum time for which foo can study continuously without taking stress.

“TESTCASE_1”: “2 2 2 2 10\n###—###SEPERATOR—###—\n1”, “TESTCASE_2”: “2 3 5 7 1000\n###—###SEPERATOR—###—\n7”, “TESTCASE_3”: “53 59 29 2 276142\n###—###SEPERATOR—###—\n16”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

**ANSWER**

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long int ll;
const int MAX_N=100005;
int main()
{
//ll *arr=(ll*)malloc((MAX_N)*sizeof(ll));
ll a,b,c,d,k,val;
scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&k);
int n=(int)(ceil(cbrt(k/a)));
val=a*n*n*n+b*n*n+c*n+d;
while(val>k&&d<k)
{
n--;
val=a*n*n*n+b*n*n+c*n+d;
}
printf("%d\n",n );
return 0;
}
```