코딩테스트

[백준]2745, 11005

이수민 2023. 4. 2. 00:50
#2745
a,b=input().split()
b= int(b)
total=0
a=reversed(a)
mul=1
for i in a:
  if(ord(i)>64):
    total+=(ord(i)-55)*mul
  else:
    total+=int(i)*mul
  mul=mul*b
print(total)
#11005
n, b=map(int,input().split())
num = ""
while n:
  temp=n%b
  if(temp>=10):
    num=chr(temp+55)+num
  else:
    num=str(temp)+num
  n=n//b
print(num)