匿名计算平均工资
Quant Salary
题目详情
8 个量化从业者想计算行业平均工资,但没人愿意向他人透露自己的工资。如何在不暴露任何个人工资的情况下,集体计算平均工资?
Eight quants each want to know the average salary in their industry, but no one wants to reveal their own salary to the others. How can they collectively compute the average without exposing any individual’s salary?
解析
使用“随机掩码 + 逐步累加”方法:
- 第 1 人选一个大随机数 ,把 传给第 2 人。
- 第 2 人加上自己的工资 ,传给第 3 人……依次类推。
- 最后一个人得到 ,传回第 1 人。
- 第 1 人减去 得到总和 ,再除以 8 得平均数。
他人只看到“部分和”,看不到任何单个人的工资。
Original Explanation
They can use a secure “random offset” method. For example:
- The first person picks a random large number and adds it to their salary , writing down (hidden from others except passing along a sum).
- They pass this partial sum to the second person, who adds , etc.
- Finally, the sum is returned to the first person, who subtracts , leaving .
- Divide by 8 for the average.
No one sees each other’s salaries, only partial sums.