Блог пользователя 8shubham

Автор 8shubham, история, 7 лет назад, По-английски

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 ?

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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 лет назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    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 лет назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      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 лет назад, # ^ |
          Проголосовать: нравится +3 Проголосовать: не нравится

        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 !!