P1625 Summation
Description
When Gauss was still a kid, he found that
$$\sum_{i=1}^n i= \frac{n \times (n+1)}{2}.$$
When LT was still a kid, he found that
$$\sum_{i=1}^{n-1} \frac{1}{i\times (i+1)}=1-\frac{1}{n}.$$
Now, while you are still a kid, you need to compute:
$$\sum_{i=1}^n \frac{1}{\prod_{j=i}^{i+m-1}j}=S.$$
Input Format
Input two integers $n, m$.
Output Format
Output two lines. The first line contains an integer $X$, and the second line contains an integer $Y$, indicating that $S=\frac{X}{Y}$, and $X$ and $Y$ are coprime.
Explanation/Hint
$m>1$, $n>0$.
$50 \%$ of the testdata satisfy $n \leq 50$.
$100 \%$ of the testdata satisfy $n+m \leq 500$.
Translated by ChatGPT 5