/ 科创班 /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 2ms 256.0 KiB
#2 Accepted 1ms 256.0 KiB
#3 Accepted 1ms 256.0 KiB
#4 Accepted 2ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB

代码

#include <stdio.h>

int main()
{
    int a[30][30], b[30][30] = {0}, c[30][30];
    int i, j, k, l, m, n;
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            scanf("%d", &a[i][j]);
    for (i = 0; i < n; i++)
        b[i][i] = 1;
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            for (k = 0; k < n; k++)
            {
                c[j][k] = 0;
                for (l = 0; l < n; l++)
                    c[j][k] += a[j][l] * b[l][k];
            }
        }
        for (j = 0; j < n; j++)
            for (k = 0; k < n; k++)
                b[j][k] = c[j][k];
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
            printf("%d ", b[i][j]);
        printf("\n");
    }
    return 0;
}

信息

递交者
类型
递交
题目
矩阵乘法
题目数据
下载
语言
C
递交时间
2018-10-17 22:10:57
评测时间
2018-10-17 22:10:57
评测机
分数
100
总耗时
10ms
峰值内存
256.0 KiB