Logo
(追記) (追記ここまで)

15836번 - Matrix Multiplication Calculator 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB35618016054.983%

문제

Matrix multiplication is a basic tool of linear algebra, and has numerous applications in many areas of mathematics, as well as in applied mathematics, computer graphics, physics, and engineering.

We can only multiply two matrices if their dimensions are compatible, which means the number of columns in the first matrix is the same as the number of rows in the second matrix.

If A = [aij] is an m×n matrix and B = [bij] is an n×q matrix, the product AB is an m×q matrix. The product AB is defined to be the m×q matrix C = [cij] such that

\[c_{ij} = \sum_{k=1}^{n}{a_{ik}b_{kj}\]

Your task is to design a matrix multiplication calculator to multiply two matrices and display the output. If the matrices cannot be multiplied, display "undefined"

입력

The input consists of a few test cases. For each test case, the first line of input is 4 positive integers, M, N, P and Q (1 ≤ M, N, P, Q ≤ 20). M and N represent the dimension of matrix A, while P and Q represent the dimension of matrix B. The following M lines consist of the data for matrix A followed by P lines that contains the data for matrix B as shown in the sample input. The test data ends when M, N, P and Q are 0.

출력

For each test case, the output contains a line in the format "Case #x:", where x is the case number (starting from 1). The following line(s) is the output of the matrix multiplication.

제한

예제 입력 1

2 3 3 2
1 2 3
3 2 1
4 5
6 7
8 9
2 3 2 3
1 2 3
3 2 1
4 5 6
7 8 9
0 0 0 0

예제 출력 1

Case #1:
| 40 46 |
| 32 38 |
Case #2:
undefined

힌트

출처

ICPC > Regionals > Asia Pacific > Malaysia > Malaysia National Programming Contest > Al-Khawarizmi National Programming Contest 2018 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /