# 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

3904 篇文章182 人订阅

0 条评论

## 相关文章

1053

762

33310

1202

8071

### 1026 逃跑的拉尔夫

1026 逃跑的拉尔夫 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 年轻的...

3538

32110

1947

1747

1183