Skip to content

Commit a4ea807

Browse files
committed
[BOJ] 진법 변환 / 브론즈2 / 25분
https://www.acmicpc.net/problem/2745
1 parent 4c26858 commit a4ea807

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
3+
inp = sys.stdin.readline
4+
5+
arr = inp().split()
6+
7+
n = arr[0]
8+
b = int(arr[1])
9+
10+
ans = 0
11+
i = 1
12+
length = len(n)
13+
14+
for char in n:
15+
if char >= 'A' and char<='Z':
16+
ans = ans + pow(b,length - i) * (ord(char) - ord('A') + 10)
17+
else:
18+
ans = ans + pow(b,length - i) * int(char)
19+
i+=1
20+
21+
print(ans)

0 commit comments

Comments
 (0)