Originally, box $A$ has $n/2$ balls and $B$ has $n$ balls. After moving, box $A$ has $n/2-80$ balls and $B$ has $n+80$ balls. The answer to the problem is thus $$\frac{100(n/2-80)+(n+80)}{\operatorname{gcd}(n/2-80, n+80)}=\frac{51n-80 \cdot 99}{\operatorname{gcd}(n/2-80, n+80)} \stackrel{?}{=} n$$ Write $d=\operatorname{gcd}(n/2-80, n+80)=\operatorname{gcd}(n/2-80,240)$. Then the problem is equivalent $nd=51n-80 \cdot 99$ or $(51-d)n=80 \cdot 99$, with $d \mid 240$. Let's try to solve this. Either $51-d$ or $n$ must be divisible by 5. In the latter case, where $n$ is divisible by 5, we see that $d$ must be as well. Therefore $d$ is either 0 or $1 \bmod 5$. If $n$ is divisible by 4, then we know that $d$ is even and thus $51-d$ is odd. Therefore, since $16 \mid 80 \cdot 99$, $n$ must be divisible by 16, meaning that $d$ is divisible by 8. Alternatively, if $n$ is not divisible by 4, then since $16 \mid 80 \cdot 99,51-d$ must be divisible by 8, meaning that $d$ is $3 \bmod 8$. Therefore $d$ is either 0 or $3 \bmod 8$. Putting these results together, we find that $d$ must either be $0,11,16$, or $35 \bmod 40$. Since $d$ is a divisor of 240 and less than 51, we conclude that $d$ is either 16 or 40. If $d=16$, then $51-d=35$, which does not divide $80 \cdot 99$. If $d=40$, then we get $n=720$, which ends up working.
Let $n$ be the answer to this problem. Box $B$ initially contains $n$ balls, and Box $A$ contains half as many balls as Box $B$. After 80 balls are moved from Box $A$ to Box $B$, the ratio of balls in Box $A$ to Box $B$ is now $\frac{p}{q}$, where $p, q$ are positive integers with $\operatorname{gcd}(p, q)=1$. Find $100p+q$.