本帖最後由 moulin 於 2021-2-6 13:09 編輯
剛用類似組合數學的角度計算滿盤要花的寶石個數
約要花 728.775 個寶石
但我也不太清楚實際情形 XD
python 程式碼如下:
arr = [1,1,10,9,10,9,20,17,5,4,
10,7,5,3,20,9,20,7,5,2,
20,9,100,47,50,21,10,3,50,11,
100,19,100,17,20,1,50,9,100,7,
100,9,50,1,100,3,1000,9,2000,3]
def c(a,b):
ret = 1
for i in range(b):
ret *= (a-i)
for i in range(b):
ret /= i+1
return ret
ans = 0
for i in range(25):
a = arr[i*2]
b = arr[i*2+1]
tmp = 0
sta = 1
while(sta + b - 1 <= a):
tmp += sta * c(a-sta,b-1)
sta = sta + 1
ans += tmp / c(a,b)
print(ans) |