Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import sys
  2. slovnik={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F",16:'G',17:'H',18:'I',19:'J',20:'K',21:'L',22:'M',23:'N',
  3. 24:'O',25:'P',26:'Q',27:'R',28:'S',29:'T',30:'U',31:'V',32:'W',33:'X',34:'Y',35:'Z',36:'a',37:'b',38:'c',39:'d',
  4. 40:'e',41:'f',42:'g',43:'h',44:'i',45:'j',46:'k',47:'l',48:'m',49:'n',50:'o',51:'p',52:'q',53:'r',54:'s',
  5. 55:'t',56:'u',57:'v',58:'w',59:'x',60:'y',61:'z'}
  6.  
  7.  
  8.  
  9. for line in sys.stdin:
  10. sust, num = line.split(' ')
  11. sust = int(sust)
  12. num = int(num)
  13. list = []
  14. if num > 0:
  15. while num > 0:
  16. list.insert(0,num % sust)
  17. num = num//sust
  18. while list[0] == 0:
  19. list.pop(0)
  20. for x in range(len(list)):
  21. if list[x] in slovnik:
  22. list[x]= slovnik.get(list[x])
  23. print(list[x],end='')
  24. else:
  25. list[x]=int(list[x])
  26. print(list[x], end='')
  27.  
  28. else:
  29. if num < 0 :
  30. num = abs(num)
  31. while num > 0:
  32. list.insert(0, num % sust)
  33. num = num // sust
  34. while list[0] == 0:
  35. list.pop(0)
  36. print('-',end='')
  37.  
  38. for x in range(len(list)):
  39. if list[x] in slovnik:
  40. list[x]= slovnik.get(list[x])
  41. print(list[x],end='')
  42. else:
  43. list[x]=int(list[x])
  44. print(list[x], end='')
  45.  
  46. print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement