아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

First Orchard

시간 제한6초메모리 제한1024 MB

요약
네 그루의 과일 개수와 까마귀가 도착하기까지 남은 칸 수 S가 주어질 때, 까마귀보다 먼저 모든 과일을 바구니에 담을 확률을 구한다.
난이도

보통10점 중 5점

유형
확률, 동적 계획법, 시뮬레이션
정답자
아직 제출이 없습니다

문제

First Orchard is a cooperative game for children 2 years and up. In this simple game, the players pick colored fruits from trees in an orchard and place them into a basket.  To make the game more interesting, a raven tries to reach the orchard to steal the fruits. If the players are successful in moving all fruits into the basket before the raven can get to the orchard, they'll win.  If the raven gets there first, the players lose!

Your task is to determine the probability with which the players will win!

The game is played as follows. There are 4 trees in the orchard, each bearing a different type of fruit: red apples, green apples, blue plums, and yellow pears. The raven tries to reach the orchard through a pathway containing one or more steps.

At each turn, the players roll a six-sided die.  Four of the faces show a color (red, green, yellow, blue), the fifth face shows a fruit basket, and the sixth face shows a raven. All six faces can appear with equal probability. 

  • Red, Green, Yellow, Blue.  In these cases, a fruit with the corresponding color is placed into the basket, provided the tree corresponding to this color still has any fruits left to pick. Otherwise, the players move on to the next turn.
  • Fruit Basket. If the players roll the 'basket' face, they will  pick a fruit from the tree that has the largest number of fruits left.  If there are multiple such trees with the same number of  fruits, any of the trees can be chosen.
  • Raven. If the 'raven' face appears on the die, then the raven moves  one step closer towards the orchard.  

The game is over if either the players have picked all fruits, or if the raven reaches the orchard, whichever happens first. If the raven reaches the orchard before the players have placed all fruits into the basket, the players lose.

입력

The input consists of a single test case with a single line of input. The input contains five integer numbers: R G B Y S. R,G,B,YR, G, B, Y denote the number of red, green, blue, and yellow fruits initially on each tree, respectively, SS denotes the number of steps on the raven's pathway. Since the game is intended for young children, there will be at most 4 fruits of each color: 0≤R,G,B,Y≤40 \le R, G, B, Y \le 4. There will be at least one fruit overall: 0<R+G+B+Y0 < R + G + B + Y. The raven will require at least 11 and at most 88 steps: 1≤S≤81 \le S \le 8. The number of steps is equal to the number of times the raven must appear on the die for the players to lose.

출력

Output the probability that the players will win as a floating point number. The absolute error of your result should be less than 10−510^{-5}.

예제3

  1. 예제 1

    입력
    1 1 0 0 3
    
    예상 출력
    0.920138888889
    
  2. 예제 2

    입력
    4 4 4 4 5
    
    예상 출력
    0.631357306601
    
  3. 예제 3

    입력
    4 4 4 4 4
    
    예상 출력
    0.459393713591