TAAPLUSB - Editorial

@utkarsh_lath: Thanks It is more clear now

@vikrant1433: Try to understand Linearity of Expectation . The above justifications are quite clear

The sum of those two digits is exactly 9, and there was a carry from i-1th position. The sum of digits is 9 for the pairs (0, 9), (1, 8), (2, 7), … (9, 0). The probability of this happening is 10 / 100 * E[i-1].
can someone plz explain why we r multiplying E[i-1]*10/100;

1 Like

The probability that we get a carry from i-1 th place is E[i-1]. Since the digits at ith place are independent of the digits at i-1 th place, we have

Prob[there was a carry from i-1 th place and sum of digits at i th place is 9] = Prob[there was a carry from i-1 th place] * Prob[sum of digits at i th place is 9] = E[i-1] * 10/100.

1 Like

just use:

cout<<fixed <<arr[n]<<endl;

and it will get AC :slight_smile:

plz tell me how the equation E(n)=45/100+10/100*E(i-1) came??

have we include the case when the first digit for a number(N>1) is 0…we keep on counting if the sum is 9 without testing that the first number cant be 0…

shouldn’t it be (10/100)+E[i-1]
where E[1]=(45/100)??

@ utkarsh lath why have we multiplied 45/100 with i…???