luogu#P6387. [COCI 2007/2008 #4] VECI
[COCI 2007/2008 #4] VECI
Problem Description
Given a positive integer , find the smallest integer such that the number of occurrences of each digit to in is respectively equal to that in , and .
Input Format
The input contains only one line with an integer .
Output Format
Output one line with an integer representing the answer. If such a does not exist, output .
156
165
330
0
27711
71127
Hint
Constraints
For all testdata, it is guaranteed that .
Notes
Translated from COCI2007-2008 CONTEST #4 T2 VECI.
Translated by ChatGPT 5