시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB31011910641.245%

문제

1, 2, 3, 4, 5, 6, 7, 8, 9를 로마 숫자로 바꾼다면 I, II, III, IV, V, VI, VII, VIII, IX가 된다.

10, 20, 30, 40, 50, 60, 70, 80, 90은 X, XX, XXX, XL, L, LX, LXX, LXXX, XC가 된다.

100보다 작은 수를 로마 숫자로 바꾸려면, 십의 자리와 일의 자리를 따로따로 위의 방법을 이용해서 로마 숫자로 바꾼 다음, 하나로 이어 붙이면 된다.

예를 들어, 48은 XLVIII이다. 그 이유는 40을 XL로 바꾸고, 8을 VIII로 바꾼 다음, 둘을 이어 붙이면 XLVIII이기 때문이다.

로마 숫자가 주어졌을 때, 문자를 재배치했을 때 나올 수 있는 숫자 중, 가장 작은 수를 구하여 로마 숫자로 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 1보다 크거나 같고, 100보다 작은 정수 B가 로마 숫자로 주어진다.

출력

첫째 줄에, 로마 숫자 B의 문자를 재배치했을 때, 나올 수 있는 숫자 중, 가장 작은 수를 로마 숫자로 출력한다.

예제 입력 1

VII

예제 출력 1

VII

예제 입력 2

VI

예제 출력 2

IV

예제 입력 3

III

예제 출력 3

III
W3sicHJvYmxlbV9pZCI6IjI5MTUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI4NWNcdWI5YzggXHVjMjJiXHVjNzkwIFx1YzdhY1x1YmMzMFx1Y2U1OCIsImRlc2NyaXB0aW9uIjoiPHA+MSwgMiwgMywgNCwgNSwgNiwgNywgOCwgOVx1Yjk3YyBcdWI4NWNcdWI5YzggXHVjMjJiXHVjNzkwXHViODVjIFx1YmMxNFx1YWZiY1x1YjJlNFx1YmE3NCBJLCBJSSwgSUlJLCBJViwgViwgVkksIFZJSSwgVklJSSwgSVhcdWFjMDAgXHViNDFjXHViMmU0LjxcL3A+XHJcblxyXG48cD4xMCwgMjAsIDMwLCA0MCwgNTAsIDYwLCA3MCwgODAsIDkwXHVjNzQw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