#P1013. [NOIP 1998 提高组] 进制位
[NOIP 1998 提高组] 进制位
Description
To check students’ understanding of positional numeral systems, the famous scientist Lu Si gave the following addition table, where letters represent digits. For example:
$$\def\arraystretch{2} \begin{array}{c||c|c|c|c} \rm + & \kern{.5cm} \rm \mathclap{L} \kern{.5cm} & \kern{.5cm} \rm \mathclap{K} \kern{.5cm} & \kern{.5cm} \rm \mathclap{V} \kern{.5cm} & \kern{.5cm} \rm \mathclap{E} \kern{.5cm} \\ \hline\hline \rm L & \rm L & \rm K & \rm V & \rm E \\ \hline \rm K & \rm K & \rm V & \rm E & \rm \mathclap{KL} \\ \hline \rm V & \rm V & \rm E & \rm \mathclap{KL} & \rm \mathclap{KK} \\ \hline \rm E & \rm E & \rm \mathclap{KL} & \rm \mathclap{KK} & \rm \mathclap{KV} \\ \end{array}$$Its meaning is:
,,,
,,,
From these rules, we can deduce: ,,,.
We can also determine that the table represents base addition.
Input Format
The first line contains an integer () representing the number of rows.
The following lines each contain strings separated by spaces.
Let denote the string in row and column . The testdata guarantees , , , and ().
It is guaranteed that there is at most one solution.
Output Format
On the first line, output which number each letter represents, in the format like: L=0 K=1 sorted in the given letter order. Different letters must represent different digits.
On the second line, output the base of the addition.
If it is impossible to form a valid addition table, output ERROR!.
5
+ L K V E
L L K V E
K K V E KL
V V E KL KK
E E KL KK KV
L=0 K=1 V=2 E=3
4
Hint
NOIP 1998 Senior Problem 3.
Translated by ChatGPT 5
京公网安备 11011102002149号