SHARE
TWEET

Untitled

a guest Jan 24th, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. A = input()
  3. k = int(input())
  4. a = len(A)
  5. s = 0
  6. for i in range (a):
  7.     if '0' <= A[i] <= '9':
  8.         s = s + (ord(A[i]) - ord('0')) * (n ** (len(A) - 1 - i))
  9.     else:
  10.         s = s + (ord(A[i]) - ord('A') + 10) * (n ** (len(A) - 1 - i))
  11. ss = ''
  12. while s!=0:
  13.     d=s%k
  14.     s=s//k
  15.     if 0 <= d <= 9:
  16.         ss = str(d) + ss
  17.     else:
  18.         ss = chr(ord('A') + d - 10) + ss
  19. print(ss)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top