Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

8shubham's blog

By 8shubham, history, 7 years ago, In English

While solving this question on spoj when I am declaring array as long long I am getting SIGFPE Runtime error and as soon as I change it to int, it is getting accepted.

Error Code

ACed Code

I am unable to understand why this is happening because SIGFPE error occurs when we divide by zero.

Can anyone help on it ?

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

the size of your fact array is too small, increasing it and computing the right value would make it AC. The UB bug occurs as count[i]>>1 can be greater than 25.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    But see my ACed solution I have changed nothing just the cnt array from ll to int and everything seems to be working fine. I am not able to understand. How the array type can lead to SIGFPE error ?

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      well, I think the UB bug coincidentally get you AC. I am not sure as I don't have access to the inputs. But your AC code is definitely not correct as it does not count 25! and above correctly

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        Ok.. This might be the case as I was continuously getting this error so I referred to CODE to verify my ans.(He has also done the same thing)

        You are correct this is not the right method. BTW thanks !!