Simplify sprite grid distribution code.

If we count down from sqrt(count), then we're guaranteed that the first
valid rectangle we see is the best one.