Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/case-katta-rim-raqami

Writing in Roman numerals

Medium 1000 ms 64 MB 46%
Share

Write a positive integer $n$ in Roman numerals. Signs: I — $1$, V — $5$, X — $10$, L — $50$, C — $100$, D — $500$, M — $1000$. The number is written digit by digit from left to right: thousands, hundreds, tens, units. The digit of each place is written with that place's signs (I, V, X for units; X, L, C for tens; C, D, M for hundreds; M for thousands). For units: $1, 2, 3$ — I, II, III; $4$ — IV; $5$ — V; $6, 7, 8$ — VI, VII, VIII; $9$ — IX; $0$ — nothing is written. For example, $1994$ is MCMXCIV.

A number written in Roman numerals

Input

One positive integer $n$.

Output

The number in Roman numerals — capital Latin letters with no spaces.

Note

$1 \le n \le 3999$

Examples

Input #1
2026
Output #1
MMXXVI
Input #2
49
Output #2
XLIX

Sign in to submit a solution

Signing up is free and takes a minute.