17 lines
455 B
Python
17 lines
455 B
Python
import sys
|
|
|
|
|
|
def int_to_roman(input):
|
|
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
|
|
nums = ('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV',
|
|
'I')
|
|
result = ""
|
|
for i in range(len(ints)):
|
|
count = int(input / ints[i])
|
|
result += nums[i] * count
|
|
input -= ints[i] * count
|
|
return result
|
|
|
|
for num in [int(i.strip()) for i in sys.stdin]:
|
|
print int_to_roman(num)
|