Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
66901 胡海峰老师 十六进制转十进制 Python3 Accepted 29 MS 3780 KB 327 2024-03-11 11:22:09

Tests(1/1):


Code:

d ={'a':10,'b':11,'c':12,'d':13,'e':14,'f':15} def calc_value(h): res =0 p= 1 for i in range(len(h)-1,-1,-1): if h[i] in d: res += d[h[i]] *p else: res += int(h[i])*p p = p *16 return res hexvalue = input() ans = calc_value(hexvalue) print(ans)