Given a number n
(1 <= n
<= 1010), the task is to find all the possible sequences of successive positive integer numbers (p
, p+1
, ..., p+m
) that satisfy the equation: n
= p^2
+ (p+1
)2 + ... + (p+m
)2.
Input
The input consists of a single integer n
.
Output
The output is an array of strings consisting of two parts. The first element should display the total number of possible sequences, denoted as k
. The following k
elements should contain the descriptions of the sequences. Each element is a string starts with the count of numbers in the corresponding sequence, denoted as c
, followed by c
integers representing the successive positive integer numbers, separated by a space. These k
elements should be ordered in descending order of C
.
Example 1:
Input: n = 2030
Output: ["2", "4 21 22 23 24", "3 25 26 27"]
Explanation:An explanation based on EDUCATED GUESS:::There are two sequences that satisfy the equation for
n = 2030
:1. The sequence starting with
p = 21
and having4
numbers:21, 22, 23, 24
. The sum of their squares is21^2 + 22^2 + 23^2 + 24^2 = 2030
.2. The sequence starting with
p = 25
and having3
numbers:25, 26, 27
. The sum of their squares is25^2 + 26^2 + 27^2 = 2030
.Therefore, the output is
["2", "4 21 22 23 24", "3 25 26 27"]
, with the total number of sequences2
followed by the sequences in descending order of the count of numbers.
🐻

input:
output: