Sort 142 Discussions, By:
Please Login in order to post a comment
I'll rate this problem 5/5 just for the puns.
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.
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).
I think this animation http://i.imgur.com/ovjony6.gif will be helpful for problem solving
I got the correct answer, but it's showing that my answer is wrong. How?
12 8 3
10 3 3
9 10 2
Your Output (stdout)
8 3 1
2 3 7
I don't understand.
the compiler is not taking every possible output into consideration...this is not fair :)