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

相关文章:

  • 2021-05-22
  • 2022-02-12
  • 2021-11-24
  • 2021-12-28
  • 2021-11-22
  • 2022-03-01
  • 2022-02-19
  • 2021-12-29
猜你喜欢
  • 2021-12-31
  • 2021-11-04
  • 2021-10-04
  • 2021-10-29
  • 2022-02-15
  • 2021-07-08
  • 2022-12-23
相关资源
相似解决方案