标签:
1 0 1 2 0 1 2 3 4 5 6 7
0 0 1 2 1
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 const int maxn = 810; 5 int a[maxn][maxn],b[maxn][maxn],c[maxn][maxn]; 6 int main() { 7 int n; 8 while(~scanf("%d",&n)) { 9 memset(c,0,sizeof c); 10 for(int i = 0; i < n; ++i) 11 for(int j = 0; j < n; ++j) { 12 scanf("%d",a[i]+j); 13 a[i][j] %= 3; 14 } 15 for(int i = 0; i < n; ++i) 16 for(int j = 0; j < n; ++j) { 17 scanf("%d",b[i]+j); 18 b[i][j] %= 3; 19 } 20 for(int i = 0; i < n; ++i) 21 for(int k = 0; k < n; ++k) 22 for(int j = 0; j < n; ++j) 23 c[i][j] += a[i][k]*b[k][j]; 24 for(int i = 0; i < n; ++i) { 25 for(int j = 0; j + 1 < n; ++j) 26 printf("%d ",c[i][j]%3); 27 printf("%d\n",c[i][n-1]%3); 28 } 29 } 30 return 0; 31 }
HDU 4920 Matrix multiplication
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/4720299.html