boris-vlasenko

to rim

Oct 29th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. R=['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', 'I', 'I', 'I']
  2. A=[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 3, 2, 1]
  3.  
  4. a = int(input())
  5. res = ''
  6. i = 0
  7. while a > 0:
  8.     if a >= 1000:
  9.         a -= 1000
  10.         res += 'M'
  11.     if a >= 900:
  12.         a -= 900
  13.         res += 'CM'
  14.     if a >= 500:
  15.         a -= 500
  16.         res += 'D'
  17.     if a >= 400:
  18.         a -= 400
  19.         res += 'CD'
  20.     if a >= 100:
  21.         a -= 100
  22.         res += 'C'
  23.     if a >= 90:
  24.         a -= 90
  25.         res += 'XC'
  26.     if a >= 50:
  27.         a -= 50
  28.         res += 'L'
  29.     if a >= 40:
  30.         a -= 40
  31.         res += 'XL'
  32.     if a >= 10:
  33.         a -= 10
  34.         res += 'X'
  35.     if a >= 9:
  36.         a -= 9
  37.         res += 'IX'
  38.     if a >= 5:
  39.         a -= 5
  40.         res += 'V'
  41.     if a >= 4:
  42.         a -= 4
  43.         res += 'IV'
  44.     if a >= 1:
  45.         a -= 1
  46.         res += 'I'
  47. print(res)
Advertisement
Add Comment
Please, Sign In to add comment