9 条题解

  • -8
    @ 2021-12-17 21:35:32
    #include <bits/stdc++.h>
    #include <windows.h>
    #define ll long long
    #define mod 1000000007
    #define maxn 510
    inline int read()
    {
        int X = 0; bool f = false; char ch = getchar();
        while (ch > '9' || ch < '0') {f |= ch == '-'; ch = getchar();}
        while (ch <= '9' && ch >= '0') {X = (X << 3) + (X << 1) + (ch ^ 48); ch = getchar();}
        return f ? -X : X;
    }
    inline void write(ll X)
    {
        if (X == 0) {putchar('0'); return;}
        if (X < 0) {/*putchar('-'); X = -X;*/ X += mod;}
        short cnt = 0; char ch[31];
        while (X) {ch[++cnt] = (X % 10) ^ 48; X /= 10;}
        while (cnt) putchar(ch[cnt--]);
        return;
    }
    int n, p, m;
    ll A[maxn][maxn], B[maxn][maxn], ANS[maxn][maxn];
    int main()
    {
        n = read(); p = read(); m = read();
        for (int i = 1; i <= n; ++i) for (int j = 1; j <= p; ++j) A[i][j] = read();
        for (int i = 1; i <= p; ++i) for (int j = 1; j <= m; ++j) B[i][j] = read();
        for (int i = 1; i <= n; ++i)
        {
            for (int j = 1; j <= m; ++j)
            {
                for (int k = 1; k <= p; ++k)
                {
                    ANS[i][j] = (ANS[i][j] + (A[i][k] * B[k][j] % mod)) % mod;
                }
                write(ANS[i][j]); putchar(' ');
            }
            putchar('\n');
        }
        system("pause");
        return 0;
    }
    

    信息

    ID
    60
    时间
    2000ms
    内存
    256MiB
    难度
    3
    标签
    递交数
    803
    已通过
    203
    上传者