Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- R=['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', 'I', 'I', 'I']
- A=[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 3, 2, 1]
- a = int(input())
- res = ''
- i = 0
- while a > 0:
- if a >= 1000:
- a -= 1000
- res += 'M'
- if a >= 900:
- a -= 900
- res += 'CM'
- if a >= 500:
- a -= 500
- res += 'D'
- if a >= 400:
- a -= 400
- res += 'CD'
- if a >= 100:
- a -= 100
- res += 'C'
- if a >= 90:
- a -= 90
- res += 'XC'
- if a >= 50:
- a -= 50
- res += 'L'
- if a >= 40:
- a -= 40
- res += 'XL'
- if a >= 10:
- a -= 10
- res += 'X'
- if a >= 9:
- a -= 9
- res += 'IX'
- if a >= 5:
- a -= 5
- res += 'V'
- if a >= 4:
- a -= 4
- res += 'IV'
- if a >= 1:
- a -= 1
- res += 'I'
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment