题解 | 进制转换
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
str1 = str(input())
str2 = str1[2:]
n = len(str2)
dict_str = {'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
a1 = 0
for num in str2:
if num in dict_str:
a1 = a1 + dict_str[num]*16**(n-1)
n = n-1
else:
a1 = a1 + int(num)*16**(n-1)
n = n-1
print(a1)
#牛客创作赏金赛#
查看22道真题和解析