#P3802. Paqi Sevenfold Spell

    ID: 17052 Type: Default 1000ms 256MiB

Paqi Sevenfold Spell

Paqi Sevenfold Spell

When Paqi encounters the powerful Night Queen, Vampire Lemy, only the ultimate spell can damage her: the Paqi Sevenfold Spell. The ultimate spell is triggered when, in any consecutive 7 spells, the spell attributes are all distinct. Note that even if some of the first 6 spells have already participated in a previous triggering, as long as any 7 consecutive spells (which may overlap with a previous window) have all distinct attributes, an ultimate spell is triggered.

For example, if the spells are represented by their attribute numbers and the cast sequence is 1, 2, 3, 4, 5, 6, 7, 1, then the first 7 spells trigger one ultimate spell, and the overlapping block of the last 7 spells triggers another ultimate spell.

Paqi has 7 types of energy crystals. The i-th type of crystal can cast a spell with attribute i, and she has ai crystals of that type. Each time, she randomly chooses one of the available crystals with equal probability, uses it (consuming the crystal) and casts the corresponding spell.

Let n be the total number of crystals, i.e. n = a1 + a2 + ... + a7. A consecutive block of 7 spells will trigger an ultimate spell if it is a permutation of {1, 2, 3, 4, 5, 6, 7}. In a random permutation of the multiset of spells, for any fixed window of 7 consecutive positions, the probability that it forms a permutation of all 7 attributes is given by

$$P = \frac{7!\cdot (a_1\cdot a_2\cdots a_7)}{n(n-1)\cdots(n-6)}. $$

Since there are n - 6 such contiguous blocks (if n \ge 7), the expected number of times the ultimate spell is triggered is

$$E = (n-6) \times \frac{7!\cdot (a_1a_2\cdots a_7)}{n(n-1)\cdots(n-6)}. $$

If n < 7, it is impossible to trigger the spell, and the expected value is 0.

inputFormat

The input consists of a single line containing 7 non-negative integers a1, a2, ..., a7 separated by spaces, where ai is the number of crystals of type i. It is guaranteed that the total number of crystals does not exceed 105 (i.e. n = a1 + a2 + ... + a7 \le 105).

outputFormat

Output a single real number representing the expected number of times the ultimate spell is triggered. Your answer is considered correct if its absolute or relative error does not exceed 1e-9.

sample

1 1 1 1 1 1 1
1.0000000000