Boxs

To move all balls into one box,before the final step,there must be same
number of balls in the two box.
Represent that as (1/2,1/2),means there are 1/2 of the balls in the Box
A,and 1/2 of the balls are in the Box B.

To reach the final status (1,0),the previous status must be (1/2,1/2).
To reach status (1/2,1/2),the previous status must be (1/4,3/4).
To reach status (1/4,3/4),the previous status has to be  either
(1/8,7/4) or (3/8,5/8).
......

It covers all the statuses that be reachable to the final status.
And all fractions above has a pattern:their denominator are power of
2,and each two fractions in a status sum to 1.

So to determine whether it's possible to to move all balls into one box,
you just need to determine whether (A+B)/gcd(A,B) is a power of 2.