标签:des style blog http color java os io
1 0 1 2 0 1 2 3 4 5 6 7
0 0 1 2 1
//1703MS 7868K #include<stdio.h> #include<string.h> #define M 3 int a[807][807],b[807][807],c[807][807]; int n; void init()//建立矩阵 { for(int i=0;i<n;i++) for(int j=0;j<n;j++) { scanf("%d",&a[i][j]); a[i][j]%=M; } for(int i=0;i<n;i++) for(int j=0;j<n;j++) { scanf("%d",&b[i][j]); b[i][j]%=M; } } int main() { while(scanf("%d",&n)!=EOF) { init(); memset(c,0,sizeof(c)); for(int i=0;i<n;i++) for(int k=0;k<n;k++) if(a[i][k]) for(int j=0;j<n;j++) c[i][j]=(c[i][j]+a[i][k]*b[k][j])%3; for(int i=0;i<n;i++) { for(int j=0;j<n-1;j++) printf("%d ",c[i][j]); printf("%d\n",c[i][n-1]); } } return 0; }
HDU 4902 Matrix multiplication,布布扣,bubuko.com
HDU 4902 Matrix multiplication
标签:des style blog http color java os io
原文地址:http://blog.csdn.net/crescent__moon/article/details/38425247