A finished and an unfinished pyramid of
height .
Kim likes building Lego pyramids and now wants to build one
of height . How
many more bricks are needed if Kim already has bricks of size and bricks of size ? A pyramid is hollow and
consists of layers, as
shown in the image. The th layer has width for .
Input
Three integers , , and .
Output
Print two integers
and on a single line,
where is the number of
extra -bricks
needed and is the
number of extra -bricks. You must use as few extra bricks as possible,
so you must minimise . If there is more than one such
solution, print the one maximising .
Explanation of Sample 2
Sample input
corresponds to the situation shown in the image. Starting with
the bricks in the unfinished pyramid to the right, Kim can
build the left pyramid using an extra -brick and extra -bricks. There is no way
to finish a height-
pyramid with fewer than extra bricks. Note that it is also
possible to build a height- pyramid using extra bricks of size (and no extra -bricks). However, the
sample output is correct because it uses more extra
-bricks.
Sample Input 1 |
Sample Output 1 |
1 1 0
|
0 0
|
Sample Input 2 |
Sample Output 2 |
4 2 7
|
1 4
|
Sample Input 3 |
Sample Output 3 |
3 0 0
|
1 6
|
Sample Input 4 |
Sample Output 4 |
1 0 5
|
1 0
|