### COCI 2008/2009, Contest #1

Three kangaroos are playing in the desert. They are playing on a number line, each occupying a different integer. In a single move, one of the outer kangaroos jumps into the space between the other two. At no point may two kangaroos occupy the same position.

Help them play as long as possible.

### Input

Three integers A, B and C (0 < A < B < C < 100), the initial positions of the kangaroos.

### Output

Output the largest number of moves the kangaroos can make.

`2 3 5`

`1`

`3 5 9`

### Output

`3`

Point Value: 5
Time Limit: 1.00s
Memory Limit: 32M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (1/0)
find out the bigger difference between he first and second kangaroo and second and third kangaroo.

• (0/1)
Three positions are given initially(x<y<z).x can jump between y and z and similarly z can jump between x and y.In first case(x jumping) x can take position from y+1,y+2,y+3...till (z-1).Similarly if z jumping it can take position from (x+1,x+2x+3...till (y-1)).

• (0/0)
I get Time Limit Exceeded for test case 1 and test case 9. That is all.

• (0/0)
There is a much simpler way to do this problem without loops.
However, I can't see anything wrong with your code except maybe you're going into an infinite loop. Try the smallest test cases, and then some bigger ones.

• (1/0)
You get TLE, which of course means your program runs forever. This is caused by your whole program being wrong - debug it and observe the values of your 3 position variables, and see if they satisfy a<b<c (as your program requires them to).

• (0/0)
Thx

• (0/0)
Hint: What do you notice about the last two numbers and the output?

• (0/0)
Oh. I see you got the problem. Nvm then.

• (0/0)
Is there a specific formula for it like chocolate bar?
if so, can someone give me test cases?

• (0/0)
The distinction between "formula" and "algorithm" is blurred. Anyway, look at the point value. This problem's only worth 5 points, so there's a good chance that the solution is short and simple. Try working out some test cases by hand and maybe you'll see a pattern.

• (0/0)
Come on just one test case i really need the points...

• (0/0)
How will testcases help? Each one is just 3 numbers, you can come up with those yourself.

• (0/2)
so if there is a kangaroo at 1 and 3 and 5;

the one on 1 cna jump any where between 3 and 5? or between 1 and 5??

• (0/0)
Just between 3 and 5 (between the other two!)

• (0/0)
and to maximize the num of jumps, it is practically going to occupy the space of 4 on the number line.

• (0/1)
does that mean that the kangaroos can jump above each other?

if x<y<z then x can jump between z and y?

• (1/0)
yea if x<y<z then either x jumps at any spot between y and z or z jumps at any spot between x and y

• (1/1)
can someone tell me what am I doing wrong?

Does the question mean that these kangaroos cant jump away from one another? like can one of them go towards the end of the number line?

• (2/0)
In a certain sense the kangaroos indeed cannot jump away from one another. I thought the problem statement was very clear. If the kangaroos are at positions x, y, z, where x < y < z, then either the kangaroo at x may jump to any position y+1, y+2, ... z-2, z-1 or the kangaroo at z may jump to any position x+1, x+2, ... y-2, y-1.