for k1 := ...
for k2 := ...
for k5 := ...
for k10 := ...
for k20 := ...
if k1 * 1 + k2 * 2 + .. + k20 * 20 = sum then
writeln(k1, '*1 + ', k2, '*2 + ' , ...);
for k1 := 0 to sum div 1 + 1 do
for k2 := 0 to sum div 2 + 1 do
for k5 := ...
for k10 := ...
for k20 := ...
if k1 * 1 + k2 * 2 + .. + k20 * 20 = sum then
writeln(k1, '*1 + ', k2, '*2 + ' , ...);