#include #include using namespace std; int toInt(string s) { int ans=0; int prev = 0; for(int i=s.length()-1; i>=0; i--) { int temp=0; char ch = s[i]; switch (ch) { case 'I' : temp = 1; break; case 'V' : temp = 5; break; case 'X' : temp = 10; break; case 'L' : temp = 50; break; case 'C' : temp = 100; break; case 'D' : temp = 500; break; case 'M' : temp = 1000; break; } if (temp >= prev) ans += temp; else ans -= temp; prev = temp; } return ans; } string toRoman(long val) { int i; string ans=""; if (val >= 1000) { for(i=0; i= 900) { ans += "CM"; val -= 900; } if (val >= 500) { ans += "D"; val -= 500; } if (val >= 400) { ans += "CD"; val -= 400; } if (val >= 100) { for(i=0; i= 90) { ans += "XC"; val -= 90; } if (val >= 50) { ans += "L"; val -= 50; } if (val >= 40) { ans += "XL"; val -= 40; } if (val >= 10) { for(i=0; i= 5) { ans += "V"; val -= 5; } if (val == 4) { ans += "IV"; val -= 4; } if (val >= 1) { for(i=0; i> n; while (n > 0) { icase++; total = 0; for(i=0; i> num; total += toInt(num); } cout << "Case " << toRoman(icase) << ": " << toRoman(total) << endl; cin >> n; } return 0; }