#P6636. 「JYLOI Round 1」性状
「JYLOI Round 1」性状
Problem Description
Xiao Guo gives you non-negative integers . For any , we have . Here, represents the number of dominant genes in the -th person's genotype that control having a double eyelid, and in the following it also represents this organism.
Now, for any subsequence of the original sequence (where , and ), we mate with to obtain the 1st generation offspring, then mate that offspring with to obtain the 2nd generation offspring, and so on. Finally, we mate the -th generation offspring with to obtain the -th generation offspring. We define the value of this subsequence as the probability that the -th generation offspring has double eyelids.
Since he is very busy, he asks you to compute the average value of all subsequences, and output it modulo .
Hint: Treat 0, 1, 2 as the three strings aa, Aa, AA. Mating two organisms means selecting a length subsequence from each string, and merging them with the uppercase letter first and the lowercase letter second. Each such resulting string is one possible genotype of the offspring.
Those starting with an uppercase letter are dominant traits, and those starting with a lowercase letter are recessive traits. Double eyelids are a dominant trait, and single eyelids are a recessive trait. Then map aa, Aa, AA back to the numbers 0, 1, 2.
Note: In this problem, we assume that whether someone has double or single eyelids is controlled by a pair of alleles A and a on an autosome, where A is completely dominant over a. The inheritance of this trait follows Mendel's law of segregation. We do not consider epigenetics, sex-linked inheritance, mutations, or interactions among gene expressions. No genotype has any lethal probability at the gamete or individual level, and all individuals can produce fertile gametes.
Input Format
The first line contains a positive integer , separated by a space, where the meaning of is as described above.
The second line contains non-negative integers. The -th number in this line represents .
Output Format
Output a single line containing one non-negative integer, which is the answer.
2
2 1 0
415935148
50
2 1 2 1 0 0 2 2 0 0 1 2 0 0 0 2 0 0 1 2 1 1 1 1 1 0 1 1 1 0 1 2 0 1 1 0 1 1 2 0 1 0 0 1 1 1 0 1 2 1 1
576313280
Hint
Constraints
For of the testdata, .
For test point 1, .
For test point 2, .
For test points 3~5, .
For test points 6~10, .
This problem has 20 test points. Each test point is worth 5 points, for a total of 100 points.
Translated by ChatGPT 5