using System.Collections.Generic;
using System.Text.RegularExpressions;
public static object Solution(string rCash ,string rValue)
string EH = cCash+cValue;
if(cCash.Length == 0 || cValue.Length == 0){
if(Regex.IsMatch(EH,"^[MDCLXVI]+$")==false){
Dictionary<int, string> dictionary = new Dictionary<int, string>();
dictionary.Add(1000, "M");
dictionary.Add(900, "CM");
dictionary.Add(500, "D");
dictionary.Add(400, "CD");
dictionary.Add(100, "C");
dictionary.Add(90, "XC");
dictionary.Add(40, "XL");
foreach (var item in dictionary)
while (rCash.IndexOf(item.Value) == 0)
rCash = rCash.Remove(0, item.Value.Length);
foreach (var item in dictionary)
while ( rValue.IndexOf(item.Value) == 0)
rValue = rValue.Remove(0, item.Value.Length);
int diff = res_cash - res_val;
foreach (KeyValuePair<int, string> entry in dictionary)
while (diff-entry.Key>=0)
Console.WriteLine(result);
public static void Main()