Ограничения: время – 250ms/500ms, память – 512MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)
BMO and Jake play, roll the dice. It is a standard six-sided dice, with sides labelled 1 through 6. Jake the Dog changed the dice balance and some sides fall out more often than others.
For any dice, define the expected value of rolling the dice to be equal to the average of the values of the sides weighted by the probability of those sides coming up. Intuitively, this is the number you would get if you rolled the dice many times and averaged all the results together. A fair dice has an expected result of 3.5. That is, since all sides are weighed the same, they each have probability of 1/6, and we get:
`1*1/6\ +\ 2*1/6\ +\ 3*1/6\ +\ 4*1/6\ +\ 5*1/6\ +\ 6*1/6\ =\ 3.5`
BMO want make the dice more closely resemble a fair dice. To do so, BMO is going erase one side's label and replace it with a new number. But BMO don’t have a program for calculating.
You want to do so in such a way that
- The expected result of rolling the dice is 3.5, just like a fair dice, and
- The absolute value of difference between the old label and the new label on the side you change is as small as possible.
Input
The input consists of a single line with six decimal numbers, where the `i`th number (`i\ =\ 1..6`) is the probability that the side with value `i` is rolled. All of these numbers will be between 0.0 and 1.0, and they are guaranteed to sum to 1.0.
Output
Output two numbers on a single line: the label that BMO must erase and the label that he write in. Output the second number to exactly 6 decimal places, rounded.
Sample Input 1
0.16667 0.16666 0.16667 0.16667 0.16666 0.16667
Sample Output 1
1 1.000000
Sample Input 2
0.2 0.2 0.1 0.2 0.2 0.1
Sample Output 2
1 2.000000
Sample Input 3
0.0 1.0 0.0 0.0 0.0 0.0
Sample Output 3
2 3.500000