其他分享
首页 > 其他分享> > 牛客华为机试HJ69

牛客华为机试HJ69

作者:互联网

原题传送门

1. 题目描述

2. Solution 1

1、思路分析
按公式计算,
2、代码实现

import sys

if sys.platform != "linux":
    sys.stdin = open("input/HJ69.txt")

while True:
    try:
        m = int(input().strip())
        p = int(input().strip())
        n = int(input().strip())

        # dim(matrix1): m p
        # dim(matrix2): p n
        m1 = []
        for _ in range(m):
            m1.append(list(map(int, input().strip().split())))

        m2 = []
        for _ in range(p):
            m2.append(list(map(int, input().strip().split())))

        for i in range(m):
            for j in range(n):
                elem = 0
                for k in range(p):
                    elem += m1[i][k] * m2[k][j]
                print(elem, end=" ")
            print()

    except:
        break

标签:int,m2,牛客,range,m1,strip,input,机试,HJ69
来源: https://www.cnblogs.com/junstat/p/16172604.html