Please anyone clear my doubt:
question link:FLOORI4 Problem - CodeChef
In setter’s solution :CodeChef: Practical coding for everyone (correct solution),
DOUBT 1: if i remove this line:if (answer<0) answer += M;(because in solution,I don’t see any chance that ans would be negative)
That would be a wrong solution!! why??? what is the importance of that line here(in this question).
DOUBT 2: If i break the statement:answer = (ll)(answer + (i-1)* (sumfour(y) - sumfour(x)))%M;
into two individual statements like these:
answer = (ll)(answer + (i-1)* (sumfour(y) -sumfour(x)));
if(answer>=M) answer%=M;
That would again be a wrong answer!!why??what is the difference??