본문 바로가기
python-algorithm

백준 2745 진법 변환

by 무적김두칠 2021. 11. 2.

1
2
3
4
5
6
7
8
#print(ord('A')-55)
s=input().split()
n,b=s[0],int(s[1])
ans=0
for i in range(len(n)):
     if n[len(n)-i-1].isupper(): ans+=(ord(n[len(n)-i-1])-55)*pow(b,i)
     else :  ans+=int(n[len(n)-i-1])*pow(b,i)
print(ans)
cs
반응형

'python-algorithm' 카테고리의 다른 글

백준 2738 행렬 덧셈  (0) 2021.11.12
Hacker rank Print the Elements of a Linked List  (0) 2021.11.12
백준 2495 연속구간  (0) 2021.11.02
백준 1371 가장 많은 글자  (0) 2021.11.02
백준 20944 팰린드롬 척화비  (0) 2021.11.02

댓글