# Bonetrousle

# Bonetrousle

+ 3 comments I'll rate this problem 5/5 just for the puns.

+ 3 comments For b number combination, the sum distributes between min and max continuously.(min and max could be calculated by math method.) So if k in the range, there is a solution. Then we only need to add on min until it equals to k. How much is required for each number to be added could be calculated easily.

This is easy because we only need to output one legal solution. Example: 12 8 3

we could start fron 1 2 3, add 2 to each items, then we got 3 4 5 which is a solution.

Hint: 2 is got by (k - min)/b and if need there will be calculate about (k - min)%b

With this method, effiency is based on O(b).

+ 2 comments I think this animation http://i.imgur.com/ovjony6.gif will be helpful for problem solving

+ 9 comments I got the correct answer, but it's showing that my answer is wrong. How?

Input (stdin)

4

12 8 3

10 3 3

9 10 2

9 10 2

Your Output (stdout)

8 3 1

-1

8 1

8 1

Expected Output

2 3 7

-1

5 4

1 8

I don't understand.

+ 1 comment the compiler is not taking every possible output into consideration...this is not fair :)

Sort 142 Discussions, By:

Please Login in order to post a comment