luogu#P5389. [Cnoi2019] 数学课
[Cnoi2019] 数学课
Problem Description
The smart Cirno started learning calculations, so she happily computed the sum from up to .
She obtained an -term sequence: .
To check whether her calculation is wrong, she needs to pick two elements from the sequence according to some rule (the two elements may be the same), and then uniformly choose integers and to compare which one is larger.
So, she needs you to compute the probability that .
The rule: The probability of selecting the -th element of the sequence is:
$$\frac{a_i}{\sum\limits_{j=1}^n a_j}=\frac{3i\times(i+1)}{n(n+1)(n+2)}$$Input Format
Input a positive integer .
Output Format
Output the probability modulo .
2
686292993
Hint
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, , and neither nor is a multiple of .
For the last of the testdata, means is positive infinity.
Translated by ChatGPT 5