A strandon néhány doboz mokka kockacukor kiömlött a homokba. Jóska egy olyan téglatestet rakott össze kis cukorkockákból, melynek alapján az egyik irányban 1-gyel, a másikban 2-vel több sor volt, mint ahány réteg volt egymás fölött; Laci pedig kockát rakott össze, így minden cukrot fölhasználtak. Jóska kérte Lacit, adja át kockáit, azokból, az összeset fölhasználva, a téglatestet mindhárom irányban 1-1 réteggel meg tudná hosszabbítani. - Hány kis kockát épített be Jóska és hányat Laci.

A few boxes of mocha sugar cubes spilled onto the sand. Jóska built a rectangular prism out of small sugar cubes, where in one direction, there was 1 more row than the number of layers stacked on top of each other, and in the other direction, there were 2 more rows; Laci, on the other hand, built a cube, so they used up all the sugar cubes. Jóska asked Laci to give him the cubes, from which, using all of them, he could extend the rectangular prism by 1 layer in each direction. - How many small cubes did Jóska and Laci build, respectively?
I. Let the number of horizontal layers in Jóska's completed cuboid be $x-1$, and in Laci's cube $y(x-1, y$ natural numbers), then from the two expressions for the total number of candies in Jóska's imagined cuboid,

$$
\begin{gathered}
x(x+1)(x+2)=(x-1) \cdot x \cdot(x+1)+y^{3} \\
3 x(x+1)=y^{3}
\end{gathered}
$$

Here, the left side is divisible by 3, so $y^{3}$ must also be divisible by 3. This is only possible if $y$ is divisible by 3, thus the right side is divisible by 27, and the left side's $x(x+1)$ product is divisible by 9. Since these factors are consecutive natural numbers, they are relatively prime, and the divisibility can only be satisfied if either $x$ or $x+1$ is divisible by 9.

| or | $\alpha)$ | $x=a^{3}$ | and | $x+1=9 b^{3}$ |
| :---: | :---: | :---: | :---: | :---: |
| or | $\beta)$ | $x=9 c^{3}$ | and | $x+1=d^{3}$ |

For the same reason, the only additional factor of $x$ and $x+1$ can be the cube of a single integer, so

where $a, b, c, d$ are natural numbers (and thus $y=3 a b$, or $y=3 c d$).

In the first case,

$$
x=a^{3}=9 b^{3}-1
$$

and we see that the smallest possible value of $b=1$ satisfies this with $a=2$. From this, (1) has a solution $x=8$ and $y=6$, so Jóska used $7 \cdot 8 \cdot 9=504$ candies, and Laci used $6^{3}=216$ candies. After transferring the latter, Jóska's construction contained $720=8 \cdot 9 \cdot 10$ cubes. This answer is plausible because a typical 1 kg box contains about 300-400 pieces.

II. We will show that the problem has no other acceptable solution. Continuing with the $\alpha$) case, let $a=3 q+r$, where $r$ is one of the numbers $-1,0,1$. Substituting this into (2) and rearranging,

$$
r^{3}+1=9\left(b^{3}-3 q^{3}-3 q^{2} r-q r^{2}\right)
$$

is divisible by 9. Therefore, only $r=-1$ is possible, making the value in the parentheses 0. From this,

$$
q\left(3 q^{2}-3 q+1\right)=b^{3}
$$

The factors on the left side are relatively prime, so $q$ must be a cube, and since the case $q=1$ has already been seen, $q \geq 8$. Thus, $a=3 q+r \geq 23>2 \cdot 10$, and $x=a^{3}>2^{3} \cdot 10^{3}$, the number $N$ of cubes used by the two boys

$$
N=x(x+1)(x+2)>x^{3}>2^{9} \cdot 10^{9}>5 \cdot 10^{11}
$$

would represent more than $10^{9} \text{ kg}$ of sugar.

In the $\beta$) case,

$$
d^{3}=9 c^{3}+1
$$

similarly, $d$ can only be of the form $3 s+1$, so

$$
s\left(3 s^{2}+3 s+1\right)=c^{3}
$$

$s$ and $3 s^{2}+3 s+1$ are both cubes, $s=t^{3}$ and $d=3 t^{3}+1$, where $t>1$, because in the case $t=1=s$, the value in the parentheses $3+3+1=7$ is not a cube. Again, we get an unacceptable lower bound:

$$
\begin{gathered}
N>x^{3}=\left(d^{3}-1\right)^{3}=\left[\left(3 t^{3}+1\right)^{3}-1\right]^{3}>\left(27 t^{9}\right)^{3}>25^{3} t^{27} \geq \\
\geq 5^{6} \cdot 2^{27}=2 \cdot 10^{6}\left(2^{10}\right)^{2}>2 \cdot 10^{12}
\end{gathered}
$$

since $2^{10}=1024>10^{3}$. We have proven our statement.

Remark. The solution $x=8, y=6$ can also be derived from the following consideration. The left side of (1) is even, so $y$ must be divisible by $2 \cdot 3=6$. Substituting $y=6 z$ into (1), the positive solution for $x$ is

$$
x=\frac{1}{2}\left(-1+\sqrt{1+288 z^{3}}\right)
$$

and we immediately see that the discriminant is a perfect square when $z=1$.