uva 759 - The Return of the Roman Empire
#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的更多相关文章
- uva 1339
Ancient Roman empire had a strong government system with various departments, including a secret ser ...
- Ancient Cipher UVA - 1339
Ancient Roman empire had a strong government system with various departments, including a secret s ...
- LeetCode_Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- 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 ...
- LeetCodeOJ刷题之13【Roman to Integer】
Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within t ...
- LeetCodeOJ刷题之12【Integer to Roman】
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
- Leetcode 题目整理-3 Palindrome Number & Roman to Integer
9. Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. clic ...
- UVa1399.Ancient Cipher
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 五、Pandas玩转数据
Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...
随机推荐
- 转载自php100中文网 centos下lamp 环境搭建
学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一. ...
- 微软office MIME类型
后缀 MIME 類型 .docx application/vnd.openxmlformats-officedocument.wordprocessingml.document .docm app ...
- oracle 数据库连接的四种方式
Oracle Thin JDBC Driver驱动程序包名:ojdbc14.jar.ojdbc6.jar驱动程序类名: oracle.jdbc.driver.OracleDriverJDBC URL: ...
- KesionCMS V6.5后台拿SHELL方法
Title:KesionCMS V6.5后台拿SHELL方法 --2011-03-29 00:21 最近弄一个站点,是KesionCMS V6.5的WEB系统,试了下后台拿webshell方法,记下 ...
- MYSQL如何导出存储过程和触发器?
今天遇到.. 类似下面的就可以: mysqldump -u root -p -ntd -R nxsc>nxsc_trigger.sql
- [LeetCode 118] - 杨辉三角形(Pascal's Triangle)
问题 给出变量numRows,生成杨辉三角形的前numRows行. 例如,给出numRows=5,返回: [ [1], [1,1], [1,2,1], [1,3,3,1], [1, ...
- JavsScript中的Document对象
Document对象的属性 alinkColor,linkColor,vlinkColor:这些属性描述了超链接的颜色.linkColor指未访问过的链接的正常颜色,vlinkColor指访问过的链接 ...
- 51单片机C语言学习笔记4:keil C51绝对地址访问
在利用keil进行8051单片机编程的时,常常需要进行绝对地址进行访问.特别是对硬件操作,如DA AD 采样 ,LCD 液晶操作,打印操作.等等.C51提供了三种访问绝对地址的方法: 1. 绝对宏: ...
- buffer busy wait
什么是buffer busy wait? A session that reads or modifies a buffer in the SGA must first acquire the cac ...
- 什么是Ajax? (转载于疯狂客的BLOG)
Ajax的定义 Ajax不是一个技术,它实际上是几种技术,每种技术都有其独特这处,合在一起就成了一个功能强大的新技术. Ajax包括: XHTML和CSS,使用文档对象模型(Document Obje ...