hdu 4772 Zhuge Liang's Password(水题)
2014-07-06 19:49
260 查看
题目连接:hdu 4772 Zhuge Liang's Password
题目大意:给出两个n*n的矩阵,可以旋转矩阵,求两个矩阵重叠位置数值相同的位置最多为多少。
解题思路:水题,写一个矩阵旋转,然后暴力判断。
题目大意:给出两个n*n的矩阵,可以旋转矩阵,求两个矩阵重叠位置数值相同的位置最多为多少。
解题思路:水题,写一个矩阵旋转,然后暴力判断。
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 30; int n, a[2][maxn][maxn]; int solve () { int cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[0][i][j] == a[1][i][j]) cnt++; } } return cnt; } void role(int b[maxn][maxn]) { int c[maxn][maxn]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { c[j][n-i-1] = b[i][j]; } } memcpy(b, c, sizeof(c)); } int main () { while (scanf("%d", &n) == 1 && n) { for (int k = 0; k < 2; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) scanf("%d", &a[k][i][j]); } } int ans = 0; for (int i = 0; i < 4; i++) { ans = max(ans, solve()); role(a[0]); } printf("%d\n", ans); } return 0; }
相关文章推荐
- hdu 4772 Zhuge Liang's Password【模拟】水题
- HDU 4772 Zhuge Liang's Password(模拟水)
- HDU 4772 Zhuge Liang's Password(2013 Asia Hangzhou Regional Contest )
- HDU 4772 Zhuge Liang's Password 选择矩阵
- HDU 4772 Zhuge Liang's Password(暴力)
- HDU 4772 Zhuge Liang's Password (简单模拟题)
- Hdu 4772 Zhuge Liang's Password
- HDU 4772 Zhuge Liang's Password
- HDU 4772 Zhuge Liang's Password
- HDU 4772 Zhuge Liang's Password
- HDU 4772 Zhuge Liang's Password (简单模拟题)
- hdu 4772 Zhuge Liang's Password
- HDU 4772 Zhuge Liang's Password 2013杭州现场赛
- HDU 4772 Zhuge Liang's Password(模拟)
- hdu4772 水题 Zhuge Liang's Password (2013 Asia Hangzhou Regional Contest problem C)
- HDU 4772 Zhuge Liang's Password 矩阵旋转
- hdu 4739 Zhuge Liang's Mines (水题:坑题!!!)
- HDU 4739 Zhuge Liang's Mines
- hdu 4739 Zhuge Liang's Mines
- HDU 4739 Zhuge Liang's Mines