#P7773. [COCI 2009/2010 #2] RIMSKI

    ID: 8839 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟字符串2009枚举其它技巧COCI(克罗地亚)

[COCI 2009/2010 #2] RIMSKI

Background

This problem is from $\texttt{COCI 2009-2010}\ 2^\texttt{nd}\ \texttt{round}\ \text{T2 RIMSKI}$ .

The score setting follows the original problem. The full score is 5050.

Problem Description

Given a Roman numeral BB, reorder the characters of BB so that the value of the resulting numeral is as small as possible.

Input Format

One line containing a Roman numeral BB.

Output Format

One line containing a Roman numeral, the smallest value you can obtain after reordering.

VIII
VIII
VI
IV
III
III
LI
LI

Hint

1B<1001\leq B< 100.

Note: In this problem, if I appears before a larger numeral, it can only appear before V or X. The input follows the same rule. (This is why the output of sample 44 is LI instead of IL.)

Translated by ChatGPT 5