Splitting into Primes
Time limit1sMemory limit256 MB
Starting from N, repeatedly split every composite into a random divisor pair and report the expected number of rounds until all parts are prime.
- Level
Hard8 of 10
- Topics
- Probability, Dynamic programming, Number theory, Math
- Solved
- No attempts yet
Problem
A mass split is an operation on a multiset of positive integers. One mass split handles every element of at the same time. An element that is prime is left alone. An element that is not prime is replaced by the two numbers and , where is a divisor of with . Every divisor that meets the condition is equally likely, and each element draws its divisor independently.
Take as an example. 2 is prime and stays. The only divisors of 10 strictly between 1 and 10 are 2 and 5, so 10 always becomes . Each 12 picks one of 2, 3, 4, 6 with probability , which turns it into or with probability each. The first mass split therefore gives with probability , with probability , and with probability . A second mass split applied to the last of those gives and nothing else.
Start from the multiset , which holds the single element , and repeat the mass split until every element is prime. Compute the expected number of mass splits.
Input
The first line contains the number of test cases ().
Each of the next lines contains one starting value ().
Output
For each test case, print the expected number of mass splits on its own line. Round the value and print exactly six digits after the decimal point. An answer of 2 is printed as 2.000000.