leetcode Integer to Roman python
class Solution(object): def intToRoman(self, num): """ :type num: int :rtype: str """ if num > 3999 or num < 1: return "" values = [1000,900,500,400,100,90,50,40,10,9,5,4,1] numerals = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"] lists='' for i in range(0,len(values)): while num >= values[i]: num -= values[i] lists += numerals[i] return lists
@link http://www.cnblogs.com/zuoyuan/p/3779581.html