To find the smallest number possible whose sum is N and number is divisible by 10^N.
The focus should be on how to find the smallest number possible whose sum is N.
Then after then you can just simply print N zeroes.
To find the smallest number possible whose sum is equal to N you just need to decrement the number by 9 and append it to new string while the number is greater then 9. then you can just append the remainder to the string. That will be our smallest number with sum equal to N. and after that you simply print N zeroes.
Solution can be found here