Sanid's blog

By Sanid, history, 2 weeks ago,

Bob is hosting a birthday party. He has called his friends and each friend will get a cake including bob so n cakes . there are m candles to be distributed among the cakes such that every cake has at least 1 candle and the difference in number of candles between any two neighbour is not greater than one . what can be the maximum number of candles bob can get. suppose bob is at kth(1-indexed) position . sample case n=6,m=28,k=5 then bob can get 6 candles at most

• 0

 » 2 weeks ago, # |   0 Auto comment: topic has been updated by Sanid (previous revision, new revision, compare).
 » 2 weeks ago, # |   0 write a mathematical function say x is given to bob the people at distance one is given x-1 then at 2 x-2 so on.
 » 2 weeks ago, # | ← Rev. 2 →   0 My thoughts on this:You should always do m-n to get everyone at 1 candleAfter this you could add 1 to bob if you can(check his heighbors at first)If you cant add any to his neighbors, go until you either fix that or run out of candelsAnd the answer should be arr[k-1]Sorry, single_malt is right, i've got the question wrong