package crash const ( MaxHistoryLen = 100 MaxOdd = 10000 // 最大100倍 MaxWeight = 1000000 // 权重总和 ) var ( times = []int64{20000, 25000, 30000, 35000, 55000, 75000, -1} // 上涨赔率(百分位)/秒 odd = []int64{10, 20, 40, 80, 100, 150, 200} // 每个时间段对应的赔率(扩大了100倍) odds = []int64{200, 300, 500, 900, 2900, 4900, -1} ) func getTimes(t int64) int { for i, v := range times { if t <= v || v <= 0 { return i } } return 0 } func GetOdds(t int64) (odds int64) { index := getTimes(t) if index > 0 { odds += (t - times[index-1]) * odd[index] } else { odds += t * odd[0] } for i := index - 1; i >= 0; i-- { if i == 0 { odds += times[0] * odd[0] } else { odds += (times[i] - times[i-1]) * odd[i] } } odds /= 1000 return } func GetFlyTime(od int64) (t int64) { index := 0 for i := len(odds) - 2; i >= 0; i-- { if od >= odds[i] { index = i break } } if index == 0 && od <= odds[0] { return od * 1000 / odd[index] } diff := od - odds[index] return times[index] + diff*1000/odd[index+1] }