is learning about genetics in biology class. More specifically, he is learning about determining the traits of a possible offspring given the traits of its parents. He spends his days trying to determine the genetic traits of his future children. Sadly, is not very good at biology so he has asked you, his studious best friend, to calculate the probability of him having a child that looks a specific way, given the genetic details of him and his future bride!
To determine the traits of an offspring, you must find a combination of the genetic code of both parents.
In biology, traits are determined by parts of a chromosome called alleles. Alleles come in pairs, the combinations of these pairs give each person certain traits. The combination of these traits is called a genotype. Alleles can hold either dominant or recessive traits. Dominant traits are represented by capital letters whereas their recessive counterparts are denoted by a lowercase letter.
For example:
Genotype of Parent 1: AaBb
Genotype of Parent 2: AaBb
A - Dominant trait, a - recessive trait
B - Dominant trait 2, b - recessive trait 2
Possible Offspring: AABB, AABb, AAbb, AaBB, AaBb, Aabb, aaBB, aaBb, aabb
To find possible combinations of each trait, the 2 alleles from the first parent are split and combined with the 2 alleles of the trait from the second parent like so:
Given the genotype of 2 parents and the genotype of an offspring, output the probability of the parents creating an offspring with the specified genotype.
Assume that both parents and their offspring will have genotypes number of traits, .
Input Specification
The first line of input will contain one integer, .
The next 3 lines will contain the genotype of the parents and their offspring. These genotypes will all be strings of length composed of latin letters.
Note: Fast input may be required.
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
Output Specification
Output the probability of the two parents producing the specified offspring precise to 6 decimal places.
Sample Input
2
AaBb
AaBB
aaBB
Sample Output
0.125000
Explanation of Sample
The possible offspring genotypes of the two parents are:
AaBb × AaBB
× | AB | Ab | aB | ab |
---|---|---|---|---|
AB | AABB | AAbB | aABB | aAbB |
AB | AABB | AAbB | aABB | aAbB |
aB | AaBB | AabB | aaBB | aabB |
aB | AaBB | AabB | aaBB | aabB |
Of the 16 possibilities, 2 of them match the given genotype, therefore the probability of creating that specific offspring is .
Comments
Does it loop back to 'aA'?
The letters of the traits don't really matter