P3802 Little Witch Patchouli
Background
Once upon a time, there was a clever little witch named Patchouli (Paqi), whose hobby was hunting vampires.
Patchouli can skillfully use seven elemental magics: Metal, Wood, Water, Fire, Earth, Sun, and Moon. Besides using many elements, she can also combine two or more elements to cast powerful spells. For example, combining Fire and Wood to enhance attack power, or combining Fire and Earth to cover weaknesses. The variations are very rich.
Description
Now Patchouli has encountered the powerful Queen of the Night, the vampire Remi. The Queen of the Night has extremely strong vitality, so ordinary magic has little effect. Only the ultimate spell, Patchouli's Septet, can deal damage to Remi. The trigger condition for Patchouli's Septet is: among any consecutive $7$ spells, if the attributes are all different, Patchouli's Septet is triggered once.
Please note that regardless of whether the previous $6$ spells have already been part of an ultimate cast, as long as any consecutive $7$ spells have pairwise different attributes, another ultimate is triggered. For example, if we use indices to represent attributes and the casting sequence is $1, 2, 3, 4, 5, 6, 7, 1$, then the first $7$ spells trigger the ultimate once, and the last $7$ spells trigger it once again.
Now Patchouli has energy crystals of $7$ attributes. The $i$-th type of crystal can cast a spell of attribute $i$, and there are $a_i$ crystals in total. Each time a spell is cast, one of the existing energy crystals is consumed uniformly at random, and then a spell of the corresponding attribute is released.
Patchouli wants to know the expected number of times she triggers Patchouli's Septet. She cannot compute it, so she turns to you, an OI student, for help.
Input Format
A single line with $7$ integers. The $i$-th integer is $a_i$.
Output Format
Output a single real number: the answer, rounded to three decimal places.
Explanation/Hint
- Sample 1 Explanation:
Obviously, Patchouli's Septet will be triggered once.
- Constraints:
- For $30\%$ of the testdata, it is guaranteed that $\sum_{i = 1}^7 a_i \leq 10$.
- For $100\%$ of the testdata, it is guaranteed that $0 \leq a_i \leq 10^9$ and $\sum_{i = 1}^7 a_i \leq 10^9$.
Translated by ChatGPT 5