Weighted dice
Dima is delving deeper into probability theory. Recently, he acquired 2 non-standard dice. Tests in his home probability lab revealed that each die was asymmetrically weighted in an unknown manner during manufacturing. To confirm this, Dima rolled each die at least 10,000 times but no more than 100,000 times daily over several months, meticulously recording the outcomes in his scientific journal. Eventually, the calluses from this strenuous task forced him to halt the experiments, prompting him to analyze the results.
During his analysis, Dima made an intriguing discovery: each die consistently produced nearly the same number of occurrences for each face every day, a fact he promptly noted in his journal.
- "I wonder, what is the probability that if I roll both dice now, I will get a sum of S?" – this unexpected scientific question emerged for Dima.
Since writing with callused hands is challenging, Dima requests your help to write a program that can answer this question.
Although the dice are non-standard, the numbers on their faces remain the same as usual.
Input
The first two lines provide the average statistical results from the experiments for the occurrence of face number i for the first and second die, respectively. All numbers are natural and do not exceed 100,000.
The third line specifies the sum of interest S (2 ≤ S ≤ 12).
Output
Output a single number: the probability of obtaining the specified sum, rounded to 3 decimal places according to standard rounding rules.