Overflowing Uncertainty
Time limit1sMemory limit256 MB
For each interval [i,j] compute the probability that the gcd of j-i+1 independent uniform values in [1,Y] is coprime with Y, sum over all intervals, and report the numerator modulo 1e9+9 with denominator Y^N.
- Level
Hard9 of 10
- Topics
- Number theory, Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
To torment the contest participants, Wookje made a strange sequence of length N. Curiously, its elements exist only probabilistically until we look at them, each one sitting in a superposition of several positive integers. Pinning down an element requires a special process called observation.
For a positive integer Y ≥ 2 and a closed interval [ℓ, r], observation and the result of an observation are defined as follows.
Let the ℓ-th through r-th elements of the sequence be random variables Aℓ, Aℓ+1, ..., Ar. At the moment some Ai is observed, Ai is fixed to an arbitrary positive integer in the closed interval [1, Y], becoming Bi. (Every positive integer is fixed with the same probability 1/Y.) Each element is observed independently, and this yields Bℓ, Bℓ+1, ..., Br from Aℓ, Aℓ+1, ..., Ar. The result of an observation is the greatest common divisor of Bℓ, Bℓ+1, ..., Br. Observed elements immediately return to their original state and exist only probabilistically again, with no effect on later observations.
Using this sequence, Wookje defined the following strange function.
Find the integer Z satisfying the following.
Z can be extremely large, so compute its remainder modulo 10^9 + 9 and print it.
Input
The first line gives the length of the sequence N and the positive integer Y. (1 ≤ N ≤ 10^5, 2 ≤ Y ≤ 10^9)
Output
Print the remainder of the integer Z modulo 10^9 + 9.