fork download
  1. import sys
  2.  
  3. n , b = map(int,sys.stdin.readline().split(' '))
  4. a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  5. t = []
  6.  
  7. if n < b:
  8. print(n)
  9. else:
  10. while n >= b:
  11. t.append(n%b)
  12. n = n//b
  13. t.append(n)
  14. ans=""
  15. for i in range(len(t)):
  16. if t[-(i+1)] < 10:
  17. ans = ans + str(t[-(i+1)])
  18. else:
  19. ans = ans + a[t[-(i+1)]-10]
  20. print(ans)
  21.  
Success #stdin #stdout 0.03s 9664KB
stdin
34 35
stdout
34