#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. dede 日期的所有格式

    [field:pubdate function=strftime('%d',@me)/] 日 [field:pubdate function=strftime('%d日',@me)/] - [fiel ...

  2. js本地存储解决方案(localStorage与userData)

    WEB应用的快速发展,是的本地存储一些数据也成为一种重要的需求,实现的方案也有很多,最普通的就是cookie了,大家也经常都用,但是cookie的缺点是显而易见的,其他的方案比如:IE6以上的user ...

  3. 【结构型】Flyweight模式

    享元模式的主要目的.意图是为对象的大量使用提供一种共享机制.该模式的思想重在复用.共享复用.像文字.列表中的格子等这类多数都是需要考虑复用技术,否则必将大量耗费内存空间而使资源以及性能等大量耗费.该模 ...

  4. python 的内置函数(1)

     19.内置函数:              abs():求绝对值              bool():求一个值是True or False ,其中False值有 0 ,空字符串'',None,空 ...

  5. C语言刷新缓冲区(转载)

    C语言中有几个基本输入函数: //获取字符系列 int fgetc(FILE *stream); int getc(FILE *stream); int getchar(void); //获取行系列 ...

  6. 转:分享13款PHP开发框架

    文章来自于:http://mashable.com/2014/04/04/php-frameworks-build-applications/ Building software applicatio ...

  7. Linux sar使用

    [root@ywcrmdb ~]# sar -d 1 10 Linux 2.6.32-220.el6.x86_64 (ywcrmdb)  2014年04月19日  _x86_64_ (4 CPU) 1 ...

  8. COJ 0244 HDNOIP201404最短路径

    HDNOIP201404最短路径 难度级别: A: 编程语言:不限:运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 a.b.c是3个互不相等的1 ...

  9. npm包管理工具

    # 从官方包仓库中查找forever包的信息 npm search forever # 查看forever包中package.json的信息 npm view forever # 下载,安装forev ...

  10. Highcharts 带有数据标签曲线图表

    <html> <head> <meta charset="UTF-8" /> <title>Highcharts</title ...