Back
Close

We need roman not integer

Statement

 Goal

You need to convert a number N to roman
your dictionary:
I=1
V=5
X=10
L=50
C=100
D=500
M=1000
Roman rules:
Reading from left to right, add letters that represent equal or decreasing value. For example, because V=5 and I=1, VI = 5+1, VII = 5+1+1, II=1+1
A letter cannot be repeated more than 3 times in a row. For example, III is ok but IIII is not
In order to make number 4 or 9 or 40, you must add a smaller value letter in front of larger letter like V, X, etc For example IV=4, IX=9
furthermore, the small value subtraction must go in front of the letter that is closest to it in value. so MIV is valid but IMV is not because V is closer in value to I
Input
One line: An integer N
Output
One line : a string convert number N to roman
Constraints
1 ≤ N ≤ 2000
Example
Input
3
Output
III

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
3
Output
III

Validator 1 Validator
Input
4
Output
IV

Test 2 Test
Input
10
Output
X

Validator 2 Validator
Input
19
Output
XIX

Test 3 Test
Input
58
Output
LVIII

Validator 3 Validator
Input
70
Output
LXX

Test 4 Test
Input
1994
Output
MCMXCIV

Validator 4 Validator
Input
2000
Output
MM

Test 5 Test
Input
1989
Output
MCMLXXXIX

Validator 5 Validator
Input
1782
Output
MDCCLXXXII

Solution language

Solution

Stub generator input