首页 > 其他 > 详细

HDU 4772 Zhuge Liang's Password(模拟水)

时间:2014-07-08 14:16:50      阅读:333      评论:0      收藏:0      [点我收藏+]

HDU 4772 Zhuge Liang‘s Password

题目链接

题意:给定两张牌,可以旋转后重叠,重合后相同数字最多的是密码,求密码

思路:直接模拟记录最大值即可

代码:

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

const int N = 35;
int n;
int a[N][N], b[N][N];

int solve() {
    int ans[4];
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < n; i++) {
	for (int j = 0; j < n; j++) {
	    if (b[i][j] == a[i][j]) ans[0]++;
	    if (b[j][n - i - 1] == a[i][j]) ans[1]++;
	    if (b[n - i - 1][n - j - 1] == a[i][j]) ans[2]++;
	    if (b[n - j - 1][i] == a[i][j]) ans[3]++;
	}
    }
    int Max = 0;
    for (int i = 0; i < 4; i++)
	Max = max(Max, ans[i]);
    return Max;
}

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]);
	printf("%d\n", solve());
    }
    return 0;
}


HDU 4772 Zhuge Liang's Password(模拟水),布布扣,bubuko.com

HDU 4772 Zhuge Liang's Password(模拟水)

原文:http://blog.csdn.net/accelerator_/article/details/37371225

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!