boris-vlasenko

P,Q, n без def

Nov 27th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. q = int(input())
  2. p = int(input())
  3. n = int(input())   
  4. pp = p
  5.  
  6. res = 0
  7. i = 0
  8. while n:
  9.         res += (n % 10) * p**i
  10.         i += 1
  11.         n = n // 10
  12. n = res
  13. p = q
  14. res = ''
  15. while n >= p:
  16.     res = str(n % p) + res
  17.     n = n // p
  18. res = str(n) + res
  19. print(res)
  20.  
  21.  
  22.  
  23.  
  24.  
  25. n = int(input())   
  26. p = q
  27.  
  28. res = 0
  29. i = 0
  30. while n:
  31.         res += (n % 10) * p**i
  32.         i += 1
  33.         n = n // 10
  34. n = res
  35. res = ''
  36. p = pp
  37. while n >= p:
  38.     res = str(n % p) + res
  39.     n = n // p
  40. res = str(n) + res
  41. print(res)
Advertisement
Add Comment
Please, Sign In to add comment