P18228 [GeeksforGeeks] Kronecker product0918
普及-
题目描述

Given a nm matrix A and a pq matrix B, their Kronecker product C = A tensor B, also called their matrix direct product, is an (np)*(mq) matrix.
A tensor B
=
|a_{11}B a_{12}B|
|a_{21}B a_{22}B|
=
|a_{11}b_{11 } a_{11}b_{12 } a_{12}b_{11 } a_{12}b_{12}|
|a_{11}b_{21 } a_{11}b_{22 } a_{12}b_{21 } a_{12}b_{22}|
|a_{11}b_{31 } a_{11}b_{32 } a_{12}b_{31 } a_{12}b_{32}|
|a_{21}b_{11 } a_{21}b_{12 } a_{22}b_{11 } a_{22}b_{12}|
|a_{21}b_{21 } a_{21}b_{22 } a_{22}b_{21 } a_{22}b_{22}|
|a_{21}b_{31 } a_{21}b_{32 } a_{22}b_{31 } a_{22}b_{32}|

Example 1:
Input:
n = 2, m = 2
p = 2, q = 2
A = {{1, 2},
{3, 4}}
B = {{0, 5},
{6, 7}}
Output: {{0, 5, 0, 10},
{6, 7, 12, 14},
{0, 15, 0, 20},
{18, 21, 24, 28}}
Explaination: If the multiplication process
is followed then this will be the answer.

Your Task:
You do not need to read input or print anything. Your task is to complete the function kroneckerProduct() which takes n, m, p, q and A and B as input parameters and returns the resultant matrix.

Expected Time Complexity: O(nmpq)
Expected Auxiliary Space: O(n
mpq)

Constraints:
1 ≤ n, m, p, q ≤ 20
1 ≤ A[i][j], B[i][j] ≤ 100

输入格式

见题面

输出格式

见题面

样例输入
n = 2, m = 2 p = 2, q = 2 A = {{1, 2}, {3, 4}} B = {{0, 5}, {6, 7}}
样例输出
{{0, 5, 0, 10}, {6, 7, 12, 14}, {0, 15, 0, 20}, {18, 21, 24, 28}}