An old Chinese poem goes:
When translated into English, this math problem reads:
100 buns and 100 monks,
Big monks eat 3 buns with no shortage,
Little monks share one bun among three,
Big and little monks, how many are there?
Once again, like in the cow and chicken problem, there is no simple calculation you can perform. You need the power of systems of equations.
Your task is to build a program that takes the following inputs, all positive integers:
- b, the number of buns.
- m, the number of monks.
- bl, the number of buns a big monk can eat.
- ms, the number of small monks who share one bun.
s, the number of big monks and small monks respectively. ("L" stands for "large").
Again, this problem has various states of solvability, but this time around, only output something if there is a unique solution in the nonnegative integers.
The shortest code to do all of the above in any language wins.
The problem input of the poem is
100 100 3 3, and the solution is