Facing Problems with ceil function

Hello I have faced this problem in one of codeforces contest and now I have this problem in the last codechef contest.In this problem when I used ceil funtion it gives me WA ,here.But when I ignore ceil funtion and add 1 if not divisible then it’s AC,here.Here in the ceil function when I am dividing the number I take (double) value of the number so that it can ceil the number.What’s wrong with my approach?And is there anything to do with time complexity here?

Similar problem I faced before-
problem Wrong Answer Accepted

Thank you.

return type of ceil() is double so better use int(ceil()) because double 2 is not exactly 2 its 2±error

1 Like

Thanks a lot :heart_eyes:

Because of these type of errors i make my own ceil function -

int mceil(int a  , int b)
   if(a%b == 0 )
       return a/b;
        return(a/b  +1);
1 Like