Given Length and Sum of Digits...

CodeForces - 489C