The thirty-five camels

Once, the great Persian mathematician Beremiz Samir (The Man Who
Counted) found three men arguing beside a batch of camels. Asked, the
older man replied:

“We are brothers. We received, an inheritance, these 35 camels.
According to the will of our father, I must get one half, my middle
brother one third, and my little brother one ninth. But we do not know
how to divide the 35 camels, because the divisions are not exact.”

“It is very simple.”—replied Beremiz. “I will justly make the division
if you allow me to add my own camel to the 35 camels of the
inheritance.”

And indeed, that way the older brother got 18 camels, which is more than
the 17 and a half that he were to receive, the middle one 12, which is
more than the 11 and some that he were to receive, and the little one 4,
which is more than the 3 and some that he were to receive. Beremiz then
continued:

“By this division that has benefited you all, 18 + 12 + 4 = 34 camels
have been distributed. Therefore, there are two spare camels. One is the
one that I added, that I recover, and the other rightly belongs to me
for having solved the difficult problem of the inheritance.”

Input

Input consists of a natural number n, followed by n cases. Each case
consists of tree fractions in one line, all made up of natural numbers
between 1 and 500, exactly following the format of the sample. Each
numerator is strictly smaller than its denominator.

Output

For each case, print a single line. If the given combination of
fractions would allow Beremiz to win exactly one camel as explained in
the story, print which should be the number of camels of the initial
batch. Print “no” otherwise.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:22:04.428Z

© Jutge.org, 2006–2026.
https://jutge.org
