n = int(input())
x = list(map(int,input().split()))
def possiblity(x, maxNum): # 计算骰子最大值不超过maxNum的种类
res = 1
for i in x:
res*=min(i,maxNum)
return res
t = max(x)
cnt = [0] * (t+1)
preSum = 0
for i in range(1,t+1):
# 最大值取到i的种类数 = 最大值不超过maxNum的种类 - 最大值不超过maxNum-1的种类
cnt[i] = possiblity(x,i) - preSum
preSum += cnt[i]
e = 0
for i in range(1,t+1):
e += i*cnt[i]/preSum
print(format(e,'.2f'))
4. 骰子期望
于 2024-03-21 19:34:48 首次发布