Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
Python:
class Solution(object):
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
digit=["","I","II","III","IV","V","VI","VII","VIII","IX"];
ten=["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"];
hundred=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"];
thousand=["","M","MM","MMM"];
return thousand[num/1000]+hundred[(num%1000)/100]+ten[(num%100)/10]+digit[num%10];
没啥意思,做了一个罗马字母的字典,然后对应求得结果。