P2518 {{[HAOI2010] Counting}}
Background
{{}}
Description
{{You are given a number. You may delete any number of digit 0s (or none) from this number, and arbitrarily reorder the remaining digits. Count how many distinct numbers smaller than the original number can be produced in this way. Note that such a number must not have a leading zero.}}
Input Format
{{Only one line, an integer $n$.}}
Output Format
{{Output a single integer, the answer.}}
Explanation/Hint
{{$n$ has length at most 50, and the answer does not exceed $2^{63}-1$.
Sample explanation: $12,21,102,120,201,210,1002$.}}
Translated by ChatGPT 5