題目描述spa
有n個骰子,每一個骰子的面數不等,第i個骰子有d[i]面,1~d[i]朝上的機率均等。問擲出這n個骰子,把朝上的點求和,問機率最大的和是多少?若是機率相等,取和最小的。骰子面數的取值爲1-10^9。ip
Byteasar is playing a tabletop role-playing game with his friends. To determine the effectiveness of their heroes' actions the players use a rather unique set of dice. The i-th (0-based) die has dice[i] faces. They are numbered from 1 to dice[i] and the face number k shows k pips. When a die is cast, every face has equal probability to come out on top. Byteasar's hero is now trying to unlock a safe containing treasure. In order to see if he succeeds, Byteasar has to guess a number M and then to roll all the dice. The safe will open if and only if M is precisely equal to the total number of pips on the topmost faces of all the dice. Obviously, the best strategy for Byteasar is to set M equal to the most probable outcome of the dice roll. You are given the vector <int> dice. Return the value M such that the probability of the total number of pips being M is the highest possible. If there are multiple such values of M, return the smallest one. |