Bonetrousle
Problem: Bonetrousle
To solve the query, we can first set a minumum set everytime, [1, 2, 3] for example. In order to make the sum of set to reach a bigger number, we can increase each number to possibly maximum number. For example, we can increase 3 to 9 to make the sum equals to 12. If the biggest available number is 8, we can first increase 3 to 8, then use the same method on the remaining leading numbers to solve the problem.
Code in Python:
t = input()
for _ in xrange(t):
n, k, b = map(int, raw_input().strip().split(' '))
if k < b:
print -1
continue
res = range(1, b+1)
s = sum(res)
if s > n:
print -1
continue
for i in xrange(b-1, -1, -1):
diff = min(n-s, k-(b-1-i)-res[i])
s += diff
res[i] += diff
if s != n:
print -1
continue
for r in res:
print r,
print