A36199. 变长编码
填空题
较难
知识点
题目描述
变长编码
参考答案
N = int(input())
N = bin(N)[2: ]
if len(N) % 7 != 0:
N = "0" * (7 - len(N) % 7) + N
bList = []
for i in range(0, len(N), 7):
bList.append(N[i: i + 7])
bList = bList[::-1]
for i, b7 in enumerate(bList[: -1]):
bList[i] = "1" + b7
else :
bList[-1] = "0" + bList[-1]
rst = ""
for b8 in bList:
rst += hex(int(b8, 2))[2: ].upper().zfill(2) + " "
rst = rst[: -1]
print(rst)
上一题
下一题