Labels

Tuesday, August 16, 2011

3 persons, how can they know the average salary of the three persons without knowing other person's salary

3 persons, how can they know the average salary of the three persons but without knowing other persons' salary. [bloomberg]
让每个人随机写一个数,传给下一个人。下一个人把自己薪水和这个数字相加传给下一个人,下一个人把这数字减去自己写的数字然后报出来。三个数字相加除以三就是三人平均薪水。
R1, R2, R3 is the random number written by person 1, 2, 3

Steps
P1
P2
P3
1
R3
R1
R2
2
R3+S1-R1
R1+S2-R2
R2+S3-R3
3
((R3+S1-R1)+(R1+S2-R2)+(R2+S3-R3))/3=(S1+S2+S3)/3

or
P1 produce a random number R1, pass S1+R1 to P2, P2 pass S1+R1+S2 to P3, P3 pass S1+R1+S2+S3 back to P1. Then P1 abstract R1, speak out R1+R2+R3/3

No comments:

Post a Comment