You are not logged in. Please login at www.codechef.com to post your questions!

×

RE(SIGFPE)

include <iostream>

using namespace std;

include<stdio.h>

include<stdlib.h>

include<algorithm>

include <cstdlib>

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;

}

asked 22 Dec '18, 18:52

rawatsir's gravatar image

2★rawatsir
1
accept rate: 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.

link

answered 22 Dec '18, 18:55

masood786's gravatar image

4★masood786
1063
accept rate: 13%

edited 22 Dec '18, 19:00

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.

link

answered 22 Dec '18, 19:29

arnavvarshney's gravatar image

3★arnavvarshney
1548
accept rate: 9%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,739
×525
×135
×78
×47
×19
×16
×6

question asked: 22 Dec '18, 18:52

question was seen: 79 times

last updated: 22 Dec '18, 19:29