Balanced centrifuge configurations
This is not a review, but an extended comment.

The code cannot be meaningfully optimized. Few notes though.


First, thou shalt not bruteforce. It is almost inevitably wrong.
Next, you must realize that it is a number-theoretical problem. Even the names of the test cases suggest so. Among other things it means that testing the sum against 1e-10 is not right.
Finally, do watch the video referenced in the problem. It is a big spoiler, and it doesn't provide a proof of the claim. The proof is far from trivial; if you are interested in the proof, follow up with this is a fascinating reading (trigger warning: heavy-duty math).