题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
import sys def trans16(x): # 先备份下十六进制各个字符的对应数字 rtn={'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9, 'A':10,'B':11,'C':12,'D':13,'E':14,'F':15} return rtn[x] for line in sys.stdin: line=line.replace('\n','')#清除可能存在的换行符 numList=list(line[2:]) i=0 size=len(numList) sum=0 while(i<size): n=trans16(numList[i]) for k in range(size-i-1): n*=16 sum+=int(f"{n}") i+=1 print(sum)