P8115 "RdOI R3.5" Table
Background
Little A wants to solve the problem by tabulating the answers, but the code is too long. He realized that writing numbers in hexadecimal can sometimes be shorter than writing them in decimal, so he decided to rewrite the answer table in hexadecimal.
Description
In this problem, all “hexadecimal” numbers are written using digits $0\sim 9$ and uppercase letters $\tt A\sim F$, and each hexadecimal number has the prefix $\colorbox{#ddd}{\tt 0x}$.
You are given several decimal integers enclosed in braces and separated by commas, representing Little A’s answer table. You need to rewrite each number in the table as follows:
- If the number of characters used when writing this integer in hexadecimal is less than or equal to that in decimal, rewrite it in hexadecimal.
- Otherwise, keep it in decimal unchanged.
Output the rewritten answer table.
Input Format
- Read one line containing a string. The string contains only braces, commas, and digits, with no spaces or other characters. The exact format can refer to the array definition format in C++. It represents Little A’s answer table, and the format is guaranteed to be correct.
Output Format
- Output one line containing a string, representing the rewritten answer table.
Explanation/Hint
### Sample Explanation
#### Sample \#1
- $1$ is written in hexadecimal as $\tt 0x1$, which has $3$ characters, longer than the $1$ character in decimal.
- $314159$ is written in hexadecimal as $\tt 0x4CB2F$, which has $7$ characters, longer than the $6$ characters in decimal.
- $3141592653589793$ is written in hexadecimal as $\tt 0xB29430A256D21$, which has $15$ characters, shorter than the $16$ characters in decimal.
#### Sample \#2
The input is an empty array, so the output should also be an empty array.
### Constraints and Notes
This problem has five test points. Each test point is worth 20 points, and the total score is the sum of the scores of all test points.
Suppose there are $n$ integers in the answer table, denoted as $a_1,a_2,\cdots,a_n$. For $100\%$ of the data, $0\le n\le10^3$, and $0\le a_i < 2^{64}$.
Translated by ChatGPT 5