시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 104 42 38 41.758%

문제

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

VI

예제 출력 1

IV
W3sicHJvYmxlbV9pZCI6IjI5MTUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI4NWNcdWI5YzggXHVjMjJiXHVjNzkwIFx1YzdhY1x1YmMzMFx1Y2U1OCIsImRlc2NyaXB0aW9uIjoiPHA+XHJcblx0MSwgMiwgMywgNCwgNSwgNiwgNywgOCwgOVx1Yjk3YyBcdWI4NWNcdWI5YzggXHVjMjJiXHVjNzkwXHViODVjIFx1YmMxNFx1YWZiY1x1YjJlNFx1YmE3NCBJLCBJSSwgSUlJLCBJViwgViwgVkksIFZJSSwgVklJSSwgSVhcdWFjMDAgXHViNDFjXHViMmU0LjxcL3A+XHJcbjxwPlxyXG5cdDEwLCAyMCwgMzAsIDQwLCA1MCwgNjAsIDcwLCA4MCwgOTBcdWM3NDAgWCwgWFgsIFhYWCwgWEws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