Expected value is linear regardless of whether the underlying events are independent,
which is what makes this calculation so much simpler than it first appears. Genetic counsellors use
exactly this reasoning to estimate how many children in a cohort will express a trait, and the same
linearity argument underpins the expected-count calculations in every population genetics model.
Statement
You are given six integers giving the number of couples in a population with each of
these genotype pairings, in order:
AA x AAAA x AaAA x aaAa x AaAa x aaaa x aa
Every couple produces exactly two offspring.
Compute the expected number of offspring displaying the dominant phenotype, and print it to five
decimal places.
The probability that a single offspring shows the dominant phenotype is 1.0 for the first three
pairings, 0.75 for the fourth, 0.5 for the fifth, and 0.0 for the sixth.
Input — read from standard input
| Variable | Type | Description |
|---|---|---|
counts
line 1
|
str |
Six space-separated integers, the number of couples of each genotype pairing
each count between 0 and 20000
|
These variables are already read for you in the starter code on the right.
Output
str expected number of dominant-phenotype offspring, to five decimal places
Sample Cases
1 0 0 1 0 1
3.50000
18 15 6 27 24 30
142.50000
Submit also runs your code against 5 hidden test cases. Hidden inputs are never shown — if one fails you'll get its number and a description of the mismatch, not the data.
Constraints
- Exactly six integers on one line, separated by single spaces
0 <= each count <= 20000- Every couple produces exactly two offspring
- Output exactly five decimal places
Further Reading
- Expected value is linear, so you can sum each pairing's contribution independently.
- The contribution of a pairing is
count * 2 * probability. - No combinatorics are needed at all — this is a weighted sum, nothing more.