标签:tor res str 原因 pytho tco 字典 ble ber
思路:https://leetcode-cn.com/problems/integer-to-roman/solution/tan-xin-suan-fa-by-liweiwei1419/
class Solution(object):
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
numbers = [('M',1000), ('CM',900), ('D',500), ('CD',400), ('C',100), ('XC',90), ('L',50), ('XL',40), ('X',10), ('IX',9), ('V',5), ('IV',4), ('I',1)]
res = []
for s, n in numbers:
if num == 0:
break
elif num >= n:
res += [s]*(num//n)
num %= n
return ''.join(res)
标签:tor res str 原因 pytho tco 字典 ble ber
原文地址:https://www.cnblogs.com/dolisun/p/11520663.html