class Solution(object):
    def intToRoman(self, num):
        """
        :type num: int
        :rtype: str
        """
        one_to_nigh = {
            1:'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V',
            6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX' }
        ten_to_nighty = {
            10: 'X', 20: 'XX', 30: 'XXX', 40: 'XL', 50: 'L',
            60: 'LX', 70: 'LXX', 80: 'LXXX', 90: 'XC'
        }
        hundred_to_thun = {
            100: 'C', 200: 'CC', 300: 'CCC', 400: 'CD', 500: 'D',
            600: 'DC', 700: 'DCC', 800: 'DCCC', 900: 'CM'
        }
        thun = {
            1000: 'M', 2000: 'MM', 3000: 'MMM'
        }
        res = ""
        div = num / 1000
        num = num % 1000
        if div:
            res += thun[div * 1000]
        div = num / 100
        num = num % 100
        if div:
            res += hundred_to_thun[div * 100]
        div = num / 10
        num = num % 10
        if div:
            res += ten_to_nighty[div * 10]

        if num:
            res += one_to_nigh[num]

        return res

if __name__ == "__main__":
    s = Solution()
    print s.intToRoman(99)
    print s.intToRoman(3455)
