What is wrong with my code

#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
long long int n,k;
cin>>n>>k;
long long int prod=1,x=1;
while(prod<=n)
{
for(int i=0;i<k;i++)
{
prod*=x;
}
if(prod<=n)
{
x++;
}
else
{
x–;
break;
}
prod=1;
}
cout<<x<<endl;
}
return 0;
}

hey @tusharnitharwal in the for loop,for(int i=0;i<k;i++) prod*=x, you need to insert a break statement ,i.e.,
if(prod>n) break; You have to use break statement here in order to avoid integer overflow because of which the code is giving garbage value as answer.
If you still have any further queries please feel free to ask.

Hey @tusharnitharwal I hope I have cleared your doubt if so please mark the doubt as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.