Fermat's polygonal number theorem Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the sum of up to three triangle numbers, four square numbers, five pentagonal numbers etc. Your task is to take a positive integer \$x\$, and an integer \$s \ge 3\$, and to output the \$s\$-gonal integers which sum to \$x\$.

The \$n\$-th \$s\$-gonal integer, where \$n \ge 1\$ and \$s \ge 3\$, can be defined in a couple of ways. The non-math-y way is that the \$n\$th \$s\$-gonal number can be constructed as a regular polygon with \$s\$ sides, each of length \$n\$. For example, for \$s = 3\$ (triangular numbers):



See here for examples with a larger \$s\$.

The math-y definition is by using the formula for \$P(n, s)\$, which yields the \$n\$-th \$s\$-gonal number:

$$P(n, s) = \frac{n^2(s-2) - n(s-4)}{2}$$

which is given in the Wikipedia page here.

Input

Two positive integers, \$s\$ and \$x\$, with the condition \$s \ge 3\$. You may input these integers in the most natural representation in your language (decimal, unary, Church numerals, integer-valued floating point numbers etc.).

Output

A list of integers, \$L\$, with a maximum length of \$s\$, where the sum of \$L\$ is equal to \$x\$ and all integers in \$L\$ are \$s\$-gonal integers. Again, the integers may be outputted in the natural representation in your language, with any distinct, consistent separator (so non-decimal character(s) for decimal output, a character different from that used for unary output etc.)

Rules


The inputs or outputs will never exceed the integer limit for your language
\$L\$ does not have to be ordered
In case of multiple possible outputs, any or all are acceptable
This is code-golf so the shortest code in bytes wins


Test cases

   x,  s =&gt; L
   1,  s =&gt; 1
   2,  s =&gt; 1, 1
   5,  6 =&gt; 1, 1, 1, 1, 1
  17,  3 =&gt; 1, 6, 10
  17,  4 =&gt; 1, 16
  17,  5 =&gt; 5, 12
  36,  3 =&gt; 36
  43,  6 =&gt; 15, 28
 879, 17 =&gt; 17, 48, 155, 231, 428
4856, 23 =&gt; 130, 448, 955, 1398, 1925
Haskell, 78 80 77 bytes

We compute the cartesian product of the first \$n\$ s-gonal numbers, and then find the first entry that sums to \$n\$.



s#n=[x|x&lt;-mapM(map(\n-&gt;s*(n^2-n)`div`2+n*(2-n)))([0..n]&lt;$[1..s]),sum x==n]!!0


Try it online!