题解 | #压缩二维码#(Python3)
压缩二维码
https://www.nowcoder.com/practice/1150d36c2cd64df9bf373988486c6723
import sys def func(n, arr): # 矩阵转字符串 s = ''.join(arr) ans = [] # 4个比特位算一个整数 for i in range(0, n*n, 4): w = 0 # 计算整数值 for k in range(0, 4): w = w * 2 + (1 if s[i+k]== '#' else 0) ans.append(w) return ans # 输入读取 while True: try: n = int(input()) n = 1<<n arr = [input() for i in range(0, n)] result = func(n, arr) for number in result: print(number, end=' ') print() except EOFError: break#15天刷题#