Problem
Convert the integer value into its standard Roman-numeral representation. Write the decimal place contributions from largest to smallest, using this symbol table:
| Symbol | Value |
|---|
I | 1 |
V | 5 |
X | 10 |
L | 50 |
C | 100 |
D | 500 |
M | 1000 |
Within a decimal place, ordinary values use the largest applicable symbol and then the remaining value. A place digit of four or nine uses its subtractive form. The only permitted subtractive pairs are IV, IX, XL, XC, CD, and CM, representing 4, 9, 40, 90, 400, and 900 respectively.
Consecutive repetition is limited to three copies of I, X, C, or M. The symbols V, L, and D cannot be repeated. Do not subtract across arbitrary decimal places: 49 is XLIX, not IL.
Preserve the original intToRoman interface: one integer argument and a string result.
Examples
Example 1
Input: value = 2449
Output: "MMCDXLIX"
The contributions are 2000, 400, 40, and 9.
Example 2
Input: value = 86
Output: "LXXXVI"
The tens contribute LXXX and the units contribute VI.
Constraints
-
1 <= value <= 3999
.
-
Return the Roman representation defined by the decimal-place and repetition rules above.