RE(SIGFPE)

#include

using namespace std;
#include<stdio.h>
#include<stdlib.h>
#include
#include

int main()
{

int t;
scanf("%d",&t);
while(t--)
 {
      long long unsigned x=1,z=1,n,i;
      scanf("%lld %lld %lld",&x,&z,&n);
      for(i=1;i<=(n/2 + n%2);i++)
      {
           x=x*2;
      }
      for(i=1;i<=n-(n/2 + n%2);i++)
      {
           z=z*2;
      }
      printf("%lld\n",max(x,z)/min(x,z));
 }


 return 0;

}

What input are you providing?

Floating point exceptions are generally caused by division by zero error, so you might wanna check into that.

Edit —> If the problem is not resolved, link the relevant code and the problem statement.

1 Like

Since you haven’t provided with the problem code, any solution would be a hypothesis.

In my opinion,

printf("%lld\n",max(x,z)/min(x,z));

is the culprit. Did you check the constraints on x and z? It probably allows either x or z to be equal to 0. Hence, min(x,z) = 0. And hence it would be a Division by 0 error. Check it out!

Also, accept the answer if it helped.