can anyone tell me how does the probability in last cast when both are 0 becomes m-1/(2*m)?? i have seen a code having this
if(!a[i] && !b[i]) { v.push_back(make_pair((((m-1)%M)*num)%M, (den*((2*m)%M))%M) ); den = (den*(m%M))%M; } somebody plz me how is the probability calculated in this case?