for(;n=readline();)print("M1000CM900D500CD400C100XC90L50XL40X10IX9V5IV4I1".replace(/(\D+)(\d+)/g,function(_,r,d)Array(0|n/d+1).join(r,n%=d)))
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page