Advertisement
Egor_1425

Untitled

Mar 22nd, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def convert(p, a, q):
  2.     rlist = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3.     acc = 0
  4.     for d in a:
  5.         r = rlist.find(d)
  6.         acc = acc * p + r
  7.     res = ""
  8.     while acc > 0:
  9.         r = acc % q
  10.         res = rlist[r] + res
  11.         acc = acc // q
  12.     return res
  13.    
  14. p = int(input())
  15. a = input()
  16. q = int(input())
  17. print(convert(p, a, q))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement