eolymp
bolt
Try our new interface for solving problems
Problems

Dolphins

Dolphins

Spring… Rabbits are happy to see sun, sky is nice and soft, flowers are blooming. Dolphins returned back from warm counties. Really, dolphins for rabbits are symbols of spring. They sing so nice, fly so nice, twirl so nice. This behavior amuses everyone. Almost… Rabbits-scientists from the Institute of dolphin population in trees tops management of the Rabbitland get a lot of work these sunny times. They need to manage big flocks of dolphins. But they hope that we will design for them an algorithm to forecast dolphin population in trees tops. Thus, we need to write a program which will find probably positions of dolphins. First it will get description of \textbf{N} dolphins, sitting at \textbf{M} trees. Every dolphin initially sits at top of some tree. Every dolphin in one second with same probability can fly to any tree with number which is prime to the number of tree where is used to sit (relatively prime integers have GCD equal to \textbf{1}), or stay at the same tree. In this way, if we have \textbf{6} trees, and dolphin is sitting at tree with number \textbf{3}, then events "\textit{dolphin in a second will be at tree with number} \textbf{1} (\textit{or} \textbf{2}, \textbf{3}, \textbf{4}, \textbf{5})" -- are equally possible. To make sure that your algorithm is correct, you need to output the sum of means of number of dolphins on trees (after \textbf{T} seconds). In other words, if \textbf{m_1}, \textbf{m_2}, ..., \textbf{m_M} -- means of number of dolphins on the first, second, …, \textbf{M}th tree we need to calculate \includegraphics{https://static.e-olymp.com/content/29/29c526a236e08d384f8d1523bb3a4599476d3284.jpg} \InputFile The first line of the input contains tree integers, separated by spaces: \textbf{N}, \textbf{M}, \textbf{T} (\textbf{1} ≤ \textbf{M}, \textbf{N}, \textbf{T} ≤ \textbf{1000}) -- number of dolphins, number of trees, time, correspondingly, to be simulated. The second line contains \textbf{N} integers, separated by spaces, which represent positions of dolphins (trees are enumerated from \textbf{1} to \textbf{M}). \OutputFile The only line at the output should have computation results with \textbf{2} digits after dot.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1 1 1
1
Output example #1
1.00
Source ACM-ICPC Ukraine 2012, 1st Stage Ukraine, April 21, 2012