哔哩哔哩20校招算法笔试题(2019.8.20)第二道编程题 AC
程序员文章站
2022-07-14 13:10:25
...
算卷积的过程
import sys
h, w = list(map(int, input().split()))
imageIn = []
for i in range(h):
imageIn.append(list(map(int, input().split())))
m = int(input())
kernel = []
for i in range(m):
kernel.append(list(map(float, input().split())))
for i in range(h - m + 1):
# row = []
for j in range(w - m + 1):
imagePatch = [ii[j:j+m] for ii in imageIn[i:i+m]]
temp = 0
for idxi, ii in enumerate(imagePatch):
for idxj, jj in enumerate(ii):
temp += jj*kernel[idxi][idxj]
# print(int(temp))
sys.stdout.write(str(int(temp)) + ' ')
# row.append(temp)
sys.stdout.write('\n')
上一篇: autoconf和automake流程
下一篇: GCC编译工具