My answer is that it cannot be done.
First, I intuited this because both 52 and 39 are multiples of 13.
Any subtaction of (52 • n1) – (39 • n2) will leave a multiple of 13.
Second, I graphed 52x – 39y = 1 on Desmos. I expanded the gridlines so that the
distance between each large division was 1. This was just to make it easier to read.
I checked the path of the curve to see if it passes through any intersection of x and y
perfectly, up to x = 20, because any x > 19 exceeds the 1,000 candies in the supply.
The curve does not pass perfectly through any intersection. This means that there
is no solution that consists of two integers.
.