A stadium scoreboard displays its running total by lighting up a row of segmented banners: one banner for every nonzero digit of the total, each banner showing that digit's own contribution at its position — that is, the digit's value multiplied by the power of ten for its place (ones, tens, hundreds, and so on). Banners are lit in order from the most significant digit down to the least significant, and a digit that is zero never lights a banner at all, since it would only display a contribution of zero.
Given the integer total n, output the sequence of nonzero place-value contributions the scoreboard would light, in order from most significant to least significant.
A single line containing the integer n.
Print the resulting contributions as space-separated integers on a single line, ordered from most significant digit to least significant. (Since n >= 1, at least one contribution is always printed.)
1 <= n <= 999999999Example 1
Input
521
Expected
500 20 1
Explanation
521 has digits 5, 2, 1 at the hundreds, tens, and ones places respectively. Contributions: 5*100=500, 2*10=20, 1*1=1. All three digits are nonzero, so all three contributions are shown in order: 500 20 1.
Example 2
Input
1004
Expected
1000 4
Explanation
1004 has digits 1, 0, 0, 4 at the thousands, hundreds, tens, and ones places. The two internal 0 digits contribute nothing and are skipped, leaving only 1*1000=1000 and 4*1=4, printed in order: 1000 4.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →