No.3331 Consecutive Cubic Sum
Reference
Consecutive Cubic Sum, Consecutive Power Sum (Small), and Consecutive Power Sum (Large) are, in this order, roughly each a generalization of the previous one.
Problem Statement
For two positive integers $L, R$, define $S(L, R)$ by $$ S(L, R) \coloneqq \sum_{i = L}^R i^3 $$ .
You are given a positive integer $N$. Find all pairs of positive integers $(L, R)$ that satisfy both of the following conditions.
- $1 \le L \le R$
- $S(L, R) = N$
Constraints
The input $N$ is an integer between $1$ and $10^{18}$, inclusive.
Input
The input is given from Standard Input in the following format.
$N$
Output
Call a pair 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, $$ (L_1, R_1), (L_2, R_2), \dots, (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$ $L_1\ R_1$ $L_2\ R_2$ $\vdots$ $L_C\ R_C$
Sample
Sample 1
Input
2025
Output
1 1 9
The following equation holds.
- $S(1, 9) = 1^3 + 2^3 + 3^3 + 4^3 + 5^3 + 6^3 + 7^3 + 8^3 + 9^3 = 2025$
$(1, 9)$ is the only solution.
Sample 2
Input
2026
Output
0
There may be no solutions at all.
Sample 3
Input
216
Output
2 3 5 6 6
There may be multiple solutions. Note that $L = R$ is allowed.
The following equations hold.
- $S(3, 5) = 3^3 + 4^3 + 5^3 = 216$
- $S(6, 6) = 6^3 = 216$
$(3, 5)$ is lexicographically smaller than $(6, 6)$, so output them in this order.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。