From 297446b1b755a08ea49693ca1558776cd85f29d1 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 6 May 2022 11:53:19 +0800 Subject: [PATCH] =?UTF-8?q?H1005=20=20=E3=80=90=E6=A8=A1=E6=9D=BF=E3=80=91?= =?UTF-8?q?=E7=9F=A9=E9=98=B5=E4=B9=98=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hydro.ac/record/62749b9f997df5291339a246 --- Hydro/system/H1005/H1005.cpp | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Hydro/system/H1005/H1005.cpp diff --git a/Hydro/system/H1005/H1005.cpp b/Hydro/system/H1005/H1005.cpp new file mode 100644 index 00000000..eb75075c --- /dev/null +++ b/Hydro/system/H1005/H1005.cpp @@ -0,0 +1,68 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1005, + mod = 1e9 + 7; + +int n, m, p; + +class Matrix { + private: + int data[N][N]; + + public: + Matrix() { + memset(data, 0x00, sizeof(data)); + } + + int* operator[](int i) { + return data[i]; + } + + Matrix operator*(Matrix b) const { + Matrix c; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= p; j++) { + for (int k = 1; k <= m; k++) { + c[i][j] = (c[i][j] + 1ll * data[i][k] * b[k][j] % mod) % mod; + } + } + } + + return c; + } +} a, b, c; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n >> m >> p; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + cin >> a[i][j]; + } + } + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= p; j++) { + cin >> b[i][j]; + } + } + + c = a * b; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= p; j++) { + cout << (c[i][j] % mod + mod) % mod << ' '; + } + cout << endl; + } + + return 0; +}