码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-07-08 14:17:11      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   2014   

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(模拟水)

标签:style   blog   http   color   os   2014   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!