$即使是1,2题也要分析时间复杂度$
import java.util.*;
public class Main
{
static final int N = 10010;
static final int D = 22;
static int[][] q = new int[N][D];
static int[][] k = new int[D][N];
static long[][] v = new long[N][D];
static long[][] temp = new long[D][D];
static long[] w = new long[N];
static int n,d;
static long process(int a, int b)
{
long ans = 0;
for(int i = 0; i < n; i++) ans = ans + k[a][i]*v[i][b];
return ans;
}
static long get(int a, int b)
{
long ans = 0;
for(int i = 0; i < d; i++) ans += q[a][i]*temp[i][b];
return ans;
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
d = sc.nextInt();
for(int i = 0; i < n; i++)
for(int j = 0; j < d; j++) q[i][j] = sc.nextInt();
for(int i = 0; i < n; i++)
for(int j = 0; j < d; j++) k[j][i] = sc.nextInt();
for(int i = 0; i < n; i++)
for(int j = 0; j < d; j++) [i][j] = sc.nextInt();
for(int i = 0; i < n; i++) w[i] = sc.nextInt();
for(int i = 0; i < d; i++)
for(int j = 0; j < d; j++) temp[i][j] = process(i,j);
for(int i = 0; i < n; i++)
{
for(int j = 0; j < d; j++)
System.out.print(get(i,j) * w[i]+" ");
System.out.println();
}
}
}