1 #include <cstdio> 2 #include <string> 3 #include <map> 4 using namespace std; 5 6 const int SIZE = 13; 7 const int value[] = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000}; 8 const string sign[] = {"I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"}; 9 10 int main() 11 { 12 map<string, int> dic; 13 for (int n = 1; n < 4000; n++) 14 { 15 int num = n; 16 string Roman = ""; 17 for(int i = SIZE - 1; i >= 0 && num; i--) 18 { 19 while(num >= value[i]) 20 { 21 Roman += sign[i]; 22 num -= value[i]; 23 } 24 } 25 dic[Roman] = n; 26 } 27 28 char s[99]; 29 while(gets(s)) 30 { 31 if(s[0] == '