|
||||
| Problem: HEX Hexadecimal Numbers
The base of the hexadecimal system is 16. In order to write down numbers in this system one uses 16 digits 0,1,...,9,A,B,C,D,E,F. The capital letters A,..,F stands for 10,..,15, respectively. For instance the value of the hexadecimal number CF2 is 12 * 162 + 15 * 16 + 2 = 3314 in the decimal system. Let X be the set of all positive integers whose hexadecimal representations have at most 8 digits and do not contain repetitions of any digit. The most significant digit in such a representation is not zero. The largest element in X is the number with the hexadecimal representation FEDCBA98, the second largest is the number FEDCBA97, the third is FEDCBA96 and so forth.
Task Write a program that:
Input The first line of the file HEX.IN contains integer n in the decimal representation.
Output Your program should write the n-th largest element in X in the hexadecimal representation to the first line of the text file HEX.OUT
Example For the text file HEX.IN: 11the correct solution is the text file HEX.OUT: FEDCBA87 Wersja do druku |