NNN-numbers
Time limit1sMemory limit1024 MB
Given N, list all N-digit base-N numbers where each digit equals how many times its position's digit value appears, in increasing order.
- Level
Medium6 of 10
- Topics
- Backtracking, Math, Implementation
- Solved
- No attempts yet
Problem
We are used to writing numbers in decimal. When we write 123, it actually stands for .
In general, a base- number uses digits from to , and stands for . When , the digits after are uppercase Latin letters in ASCII order (A = 10, B = 11, , Z = 35). For example, the base-16 number F1 stands for , which is in decimal.
An -digit NNN-number is a base- number with exactly digits in which the units digit equals the number of times digit 1 appears in it, the tens digit equals the number of times digit 2 appears, and so on. The leftmost digit equals the number of zeros in the number.
Input
The only line of the text file contains a decimal integer ().
Output
Write all -digit NNN-numbers to the text file in increasing order, one per line. If there are none, the only line of the file contains EI OLE.