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 ...
随机推荐
- Android Init进程命令的执行和服务的启动
这里开始分析init进程中配置文件的解析,在配置文件中的命令的执行和服务的启动. 首先init是一个可执行文件,它的对应的Makfile是init/Android.mk. Android.mk定义了i ...
- Web API的CPU占用100%
我用Web API做了一个网站,网站很简单,请求就是几个普通的参数,提交到服务器后,在Web API里做一下参数验证,然后去访问Redis里的TIME命令,最后把TIME命令返回的结果计算出yyyy- ...
- LIBSVM之一
libSVM简单的介绍 libSVM是台湾林智仁(Chih-Jen Lin) 教授2001年开发的一套支持向量机库,这套库运算速度挺快,可以很方便的对数据做分类或回归.由于libSVM程序小,运用灵活 ...
- Ubuntu下Git服务端搭建
1安装git $ sudo add-apt-repository ppa:git-core/ppa $ sudo apt-get update $ sudo apt-get install git 测 ...
- PCB走线和过孔的过流能力
PCB走线的载流能力与以下因素有关:线宽.线厚(铜箔厚度).容许温升.PCB走线越宽,载流能力越大. 近似计算公式: I=KT0.44A0.75 (K为修正系数,一般覆铜线在内层时取0.024,在外层 ...
- 许多js框架或js库的min版本是怎么做出来的?
如jQuery,Bootstrap,AngularJs,这些都有min版本,代码更加精简,功能却相同.看了源代码,几乎不可读. 这种事情的工具类型叫做“minifier”.请看传送门:Minifica ...
- 常用cl命令参数解释
紧接前文,第一行cl命令如下: 1> cl /c /IC:\...\include /ZI /nologo- /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG ...
- V$、GV$、X$、V_$、GV_$之间的关系
V$.GV$.X$.V_$.GV_$之间的关系 GV$:全局视图,针对多个实例环境. V$:针对某个实例的视图. X$:是GV$视图的数据来源,oracle内部表. GV_$:是GV$的同义词. V_ ...
- CSS常用操作-对齐
index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...
- hdu 4605-Magic Ball Game(树状数组)
题目大意: 给你一棵二叉树,每个节点有一个w值,现在有一颗小球,值为x,从根节点往下掉,如果w==x,那么它就会停止:如果w>x,那么它往左.右儿子的概率都是1.2:如果w<x,那么它往左 ...