python
class Solution:
def intToRoman(self, num: int) -> str:
# 罗马数字映射表
roman_map = [
(1000, "M"), (900, "CM"), (500, "D"), (400, "CD"),
(100, "C"), (90, "XC"), (50, "L"), (40, "XL"),
(10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I")
]
# 初始化结果字符串
roman = ""
# 遍历映射表
for value, symbol in roman_map:
if num == 0:
break
# 将当前数值尽可能多地减去
count = num // value
roman += symbol * count
num %= value
return roman