No.3332 Consecutive Power Sum (Small)
Reference
Consecutive Cubic Sum, Consecutive Power Sum (Small), Consecutive Power Sum (Large) are, in this order, roughly each a generalization of the previous one.
Problem Statement
For three positive integers $E, L, R$, define $S(E, L, R)$ by $$ S(E, L, R) \coloneqq \sum_{i = L}^R i^E $$ .
You are given a positive integer $N$. Find all triples of positive integers $(E, L, R)$ that satisfy both of the following two conditions.
- $1 \le L \le R$
- $S(E, L, R) = N$
Constraints
The input $N$ is an integer between $2$ and $10^{12}$, inclusive.
Input
The input is given from standard input in the following format.
$N$
Output
We call a triple satisfying the conditions in the problem statement a solution. It can be proved that there are finitely many solutions under the constraints of this problem. If there are $C$ solutions in total and they are, in ascending lexicographic order, $$ (E_1, L_1, R_1), (E_2, L_2, R_2), \dots, (E_C, L_C, R_C) $$ then output $C + 1$ lines in the following format. Separate the values on each line with spaces, and also output a newline at the end.
$C$ $E_1\ L_1\ R_1$ $E_2\ L_2\ R_2$ $\vdots$ $E_C\ L_C\ R_C$
Sample
Sample 1
Input
2
Output
1 1 2 2
The following equation holds. Note that $L = R$ is allowed.
- $S(1, 2, 2) = 2^1 = 2$
$(1, 2, 2)$ is the only solution.
Sample 2
Input
24979
Output
4 1 12489 12490 1 24979 24979 2 62 67 4 5 10
There may be multiple solutions.
The following equations hold.
- $S(1, 12\,489, 12\,490) = 12\,489^1 + 12\,490^1 = 24\,979$
- $S(1, 24\,979, 24\,979) = 24\,979^1 = 24\,979$
- $S(2, 62, 67) = 62^2 + 63^2 + 64^2 + 65^2 + 66^2 + 67^2 = 24\,979$
- $S(4, 5, 10) = 5^4 + 6^4 + 7^4 + 8^4 + 9^4 + 10^4 = 24\,979$
Output the solutions in ascending lexicographic order.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。