http://www.hackerearth.com/problem/algorithm/roy-and-sweets/ and http://www.hackerearth.com/problem/algorithm/sum-of-numbers-9/