|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||2||0||0||0.000%|
Roman numerals use symbols
M with values 1, 5, 10, 50, 100, 500, and 1000 respectively. There is an easy evaluation rule for them:
MMCDLXIX = 1000 + 1000 - 100 + 500 + 50 + 10 - 1 + 10 = 2469.
Further rules are needed to uniquely specify a Roman numeral corresponding to a positive integer less than 4000:
Rule 4 can be removed to allow shorter numerals, and still use the same evaluation rule:
IM = -1 + 1000 = 999,
ICIC = -1 + 100 + -1 + 100 = 198,
IVC = -1 -5 + 100 = 94. This would not make the numerals unique, however. Two choices for 297 would be
ICICIC. To eliminate the second choice in this example, Rule 4 can be replaced by
Finally, replace the Roman numeral symbols to make a system that is more regular and allows larger numbers: Assign the English letter symbols
Z to values 1, 5, 10, 5(10), 102, (5)102, …, 1024, (5)1024, 1025, and (5)1025 respectively. Though using the whole alphabet makes logical sense, your problem will use only symbols
a-R for easier machine calculations. (
With the new symbols
a-Z, the original formation rules 1-3, the alternate rule 4', and the evaluation rule Δ, numerals can be created, called A to Z numerals. Examples:
ad = -1 + 1000 = 999;
aAc = -1 - 5 + 100 = 94. Note that for this problem, an A to Z Numeral cannot include the same uppercase literal twice.
The input starts with a sequence of one or more positive integers less than (7)1017, one per line. The end of the input is indicated by a line containing only 0.
For each positive integer in the input, output a line containing only an A to Z numeral representing the integer.
Do not choose a solution method whose time is exponential in the number of digits!
999 198 98 297 94 666666666666666666 0
ad acac Acaaa ccAcaa aAc RrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa