**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 <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
ll a,b,c,d,k;
cin>>a>>b>>c>>d>>k;
ll t=(ll)(cbrt(k/a))+1;
while(t--){
if((d+(t)*(c+(t)*(b+a*(t))))<=k||t==0){
cout<<t<<"\n";
break;
}
}
return 0;
}
```