Percentage of white balls is an integer There are some white balls and black balls. The percentage of the white balls is an integer. Afterward, one white ball and two black balls are added. The percentage of the white balls is still an integer. What is the maximum possible number of balls at the beginning?
Let $w$ denote the number of white balls and $b$ the number of black balls initially. So $\dfrac{100w}{w+b}$ is an integer, and $\dfrac{100(w+1)}{w+b+3}$ is also an integer. How can we maximize $w+b$?
 A: I claim the largest example is $w + b = 197$ with $b = 0$ and $w = 197$. You can check that both of the given fractions are indeed integers in this case.
To see this, first let's get a good bound on things. Write $(w+b+3)l = 100w+100$ and $(w+b)k = 100w$. Subtracting one from the other gives $(w+b+3)l - (w+b)k = 100$. Write $w+b = y$ to get $yl + 3l - yk = 100$, or: $y(l-k) = 100 - 3l$. Of course, $l,k > 0$, since they are the ratio of two positive integers. In particular, this implies that $y(l-k)= 100 - 3l$.
Of course, since $w \leq y$, from $y k = 100w$ we get $k \leq 100$, and $(y+3)l  = 100(w+1) \leq 100(y+1)$ gives $l < 100$. 
Conclusion : $0 < k \leq 100, 0 < l < 100$ and we have to maximize $y=\frac{100-3l}{l-k}$. Note that this must be positive, so it is enough to check for two cases: $33 > l > k$ and $100 \geq k > l$, which are the ranges in which $y$ will be positive. 
But this is easy : Note that since $l-k$ is an integer so is at least $1$, we have $y \leq |100-3l|$ for all $0 < l < 100$, and $|100 - 3l|$ has the maximum value $197$, at the point $l = 99$. So, $y$ cannot do better than $197$.
And, it can do $197$, as my example points out. We are done.
