問題一覧 > 通常問題

No.3331 Consecutive Cubic Sum

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 68
作問者 : wasd314 / テスター : にょぐた Vi24E
お気に入りにしたユーザー ProblemId : 11795 / 自分の提出
問題文最終更新日: 2025-10-31 08:10:06
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
wasd314 さんの単発問題コンテスト (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。