0

Cake This is a e-olymp programming question mathematical optimization.

In honor of the birth of an heir Tutti royal chef has prepared a huge cake, that was put on the table for Three Fat Man. The first fat man can eat the cake by himself for t1 hours, second - for t2 hours, and the third - for t3 hours.

For what time can the cake be eaten simultaneously by all three fat men?

I had used this formula. But it is giving wrong answer.

ans=((t1/3.0)+(t2/3.0)+(t3/3.0))/3.0

Please anyone help me.

2 Answers2

2

t1 hours/cake = $\frac{1}{t1}$ cakes/hour.

For all three, they eat $\frac1{t1} + \frac1{t2} + \frac1{t3}$ cakes in one hour.

In h hours, they eat $h(\frac1{t1} + \frac1{t2} + \frac1{t3})$ cakes.

The time to eat a whole cake must satisfy $h(\frac1{t1} + \frac1{t2} + \frac1{t3})=1$ or $h = \frac1{\frac1{t1} + \frac1{t2} + \frac1{t3}}$.

user2740
  • 319
marty cohen
  • 107,799
1

The "eating speeds" are given in hours per cake. It would be better if they were given in cakes per hour (and man) cause speeds in cakes/hour are additive.