# LeetCode小白菜笔记4：Roman to Integer

LeetCode小白菜笔记[4]：Roman to Integer13. Roman to Integer [Easy]

Input is guaranteed to be within the range from 1 to 3999.

Roman numerals （罗马数字）

1-10之间的数字的最基本的表示方式（罗马数字是十进制的）

I, II, III, IV, V, VI, VII, VIII, IX, X

X, XX, XXX, XL, L, LX, LXX, LXXX, XC, C.

C, CC, CCC, CD, D, DC, DCC, DCCC, CM, M.

1776 as MDCCLXXVI, the date written on the book held by the Statue of Liberty.

1954 as MCMLIV, as in the trailer for the movie The Last Time I Saw Paris

1990 as MCMXC, used as the title of musical project Enigma’s debut album MCMXC a.D., named after the year of its release.

2014 as MMXIV, the year of the games of the XXII (22nd) Olympic Winter Games (in Sochi)

MCMLIV = 1000 + (1000-100) + 50 + (5-1)

python中的dict的key这里是字符串，要用 ‘ I ’ 而不是 I 。以及python里没有switch-case 语句 ，可能是因为有字典吧，可以实现类似的功能。

THE END

• 发表于:
• 原文链接http://kuaibao.qq.com/s/20171211G00UVQ00?refer=cp_1026
• 腾讯「云+社区」是腾讯内容开放平台帐号（企鹅号）传播渠道之一，根据《腾讯内容开放平台服务协议》转载发布内容。

2020-01-18

2018-08-29

2018-07-22

2018-07-02

2018-06-15

2018-05-31

2018-04-24