#include <cstdio>
#include <string>
#include <map>
using namespace std; const int SIZE = ;
const int value[] = {, , , , , , , , , , , , };
const string sign[] = {"I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"}; int main()
{
map<string, int> dic;
for (int n = ; n < ; n++)
{
int num = n;
string Roman = "";
for(int i = SIZE - ; i >= && num; i--)
{
while(num >= value[i])
{
Roman += sign[i];
num -= value[i];
}
}
dic[Roman] = n;
} char s[];
while(gets(s))
{
if(s[] == '\0')
{
puts("");
continue;
}
if(dic.count(s)) printf("%d\n", dic[s]);
else printf("This is not a valid number\n");
}
return ;
}

uva 759 - The Return of the Roman Empire的更多相关文章

  1. uva 1339

    Ancient Roman empire had a strong government system with various departments, including a secret ser ...

  2. Ancient Cipher UVA - 1339

      Ancient Roman empire had a strong government system with various departments, including a secret s ...

  3. LeetCode_Integer to Roman

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  4. Integer to Roman & Roman to Integer

    Integer to Roman Given an integer, convert it to a roman numeral. The number is guaranteed to be wit ...

  5. LeetCodeOJ刷题之13【Roman to Integer】

    Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within t ...

  6. LeetCodeOJ刷题之12【Integer to Roman】

    Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...

  7. Leetcode 题目整理-3 Palindrome Number & Roman to Integer

    9. Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. clic ...

  8. UVa1399.Ancient Cipher

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. 五、Pandas玩转数据

    Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...

随机推荐

  1. php urlencode()函数URL编码转换实例解析

    URLEncode:是对网页url所包含中文字符的一种编码转化方式,URLEncode有两种常见方式,一种是基于GB2312的 Encode(Baidu.Yisou等搜索引擎使用),另一种是基于UTF ...

  2. ubuntu 14.下 netbeans 自体锯齿 消除

    Ubuntu下NetBeans消除字体锯齿的方法 在netbeans.conf 文件的netbeans_default_options的最后添加 -J-Dswing.aatext=true -J-Da ...

  3. 简单DOS命令实现局域网Windows远程关机

    1秒内重启局域网内计算机名为ppgsvr-pc的用户电脑shutdown -r -m \\ComputerName -t 1 1秒内关闭局域网内ppgsvr用户电脑shutdown -s -m \\C ...

  4. Top 100 words for advanced learners.

    aberration (n.) something that differs from the norm (In 1974, Poland won the World Cup, but the suc ...

  5. 仿QQ5.0以上新版本侧滑效果

    1.此效果使用了csdn大神孙国威的代码案例在此感谢附上参考博客地址: http://blog.csdn.net/manoel/article/details/39013095/#plain 2.sl ...

  6. Linux下如何发布Qt程序

    在X11平台下qt程序,首先准备好程序中需要使用的资源,库和插件...    比如你的可运行程序取名叫作panel,那把你的panel,那些libQt*.so.4和libQt*.so.4.6.0(链接 ...

  7. Shell continue循环

    [oracle@june ~]$ cat continue.sh for i in a b c d e f g do if [ "$i" = "c" ] the ...

  8. 黑马程序员_JavaIO流(二)

    字符流的缓冲区 缓冲区的出现提高了对数据的读写效率. 对应类: BufferedWriter BufferedReader 缓冲区要结合流才可以使用. 在流的基础上对流的功能进行了增强. Buffer ...

  9. Android中sharedPreference的简单使用

    public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super ...

  10. HDU3727--Jewel (主席树 静态区间第k大)

    Jewel Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...