标签:des style blog http io color os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 931 Accepted Submission(s): 641
#include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<stdlib.h> #include<algorithm> using namespace std; const int MAXN=30+5; int a[MAXN][MAXN],b[MAXN][MAXN],n,maxn; void change() { int c[MAXN][MAXN]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) c[i][j]=a[j][n-1-i]; //矩阵旋转,模拟一下就出来 for(int i=0;i<n;i++) for(int j=0;j<n;j++) a[i][j]=c[i][j]; } int main() { while(scanf("%d",&n)&&n) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&a[i][j]); for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&b[i][j]); maxn=-1; for(int i=0;i<4;i++) { int cnt=0; for(int j=0;j<n;j++) for(int k=0;k<n;k++) if(a[j][k]==b[j][k]) cnt++; maxn=max(cnt,maxn); change(); } printf("%d\n",maxn); } return 0; }
HDU 4772 Zhuge Liang's Password (矩阵旋转)
标签:des style blog http io color os ar java
原文地址:http://www.cnblogs.com/clliff/p/4063682.html