Why lot of users are getting SIGFPE error in subtask1 of Chef and Easy Queries

In the following question(https://www.codechef.com/problems/CHEFEZQ) many of the users are getting SIGFPE error including me.
Even though there is no case where one is dividing the numerator by 0 or using a smaller data type.
Please do help me and the many other fellow coders in understanding what is causing that error.
Thank you

1 Like
         for(int i=0;i<numOfdays;i++)
	    {
	        daysTaken++;
	        scanf("%ld",&ques);
	        totalQues=totalQues+ques;
	        if(totalQues<chefAnswer)
	        {
	            checker=1;
	            break;
	        }
	        else
	        totalQues=totalQues-chefAnswer;
	    }

           in ur code if after an iteration of the for loop chefAnswer>totalQues , u r breaking the loop , so u 
           aren't taking input after that, hence "sigfpe" .
2 Likes

Thanks a lot my friend,this helped me solve my problem :slight_smile:
Actually I had the same thought as you before i even submitted my code even once and therefore i checked for error using custom input but in that case i got no error and got my result.Howsoever it caused a problem here,you know why?
BTW a lot of other user user have the same doubt and are asking about it in the editorial so i think you answer would be really appreciated there :slight_smile: