Mendel's laws are the oldest quantitative model in biology, and they are still the
first thing a genetic counsellor reaches for when a couple asks about the risk of passing on a
recessive condition. Computing the probability that two randomly chosen individuals from a population
produce offspring with a dominant phenotype is a small exercise in conditional probability, but it is
exactly the reasoning that underpins pedigree analysis and carrier screening.
Statement
A population contains k homozygous dominant individuals (AA), m heterozygous
individuals (Aa), and n homozygous recessive individuals (aa).
Two individuals are selected uniformly at random without replacement and mate.
Compute the probability that their offspring displays the dominant phenotype — that is, has at least
one A allele.
Print the probability rounded to five decimal places.
Input — read from standard input
| Variable | Type | Description |
|---|---|---|
k
line 1
|
int |
Number of homozygous dominant (AA) individuals
0 <= k <= 100
|
m
line 1
|
int |
Number of heterozygous (Aa) individuals
0 <= m <= 100
|
n
line 1
|
int |
Number of homozygous recessive (aa) individuals
0 <= n <= 100
|
These variables are already read for you in the starter code on the right.
Output
str probability of dominant phenotype in the offspring, to five decimal places
Sample Cases
2 2 2
0.78333
5 0 0
1.00000
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
- The three integers are given on one line, separated by single spaces
0 <= k, m, n <= 100andk + m + n >= 2- Selection is without replacement, so the second draw depends on the first
- Output exactly five decimal places
Further Reading
- It is easier to compute the probability of a recessive offspring and subtract from 1.
- Only three pairings can produce
aaoffspring:Aa x Aa(1/4),Aa x aa(1/2),aa x aa(1). - The number of unordered pairs from a total of
tindividuals ist*(t-1)/2.