题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772

题面:

Zhuge Liang's Password

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1404    Accepted Submission(s): 926

Problem Description
  In the ancient three kingdom period, Zhuge Liang was the most famous and smart military leader. His enemy was Sima Yi, the military leader of Kingdom Wei. Sima Yi always looked stupid when fighting against Zhuge Liang. But it was
Sima Yi who laughed to the end.

  Zhuge Liang had led his army across the mountain Qi to attack Kingdom Wei for six times, which all failed. Because of the long journey, the food supply was a big problem. Zhuge Liang invented a kind of bull-like or horse-like robot called "Wooden Bull & Floating
Horse"(in abbreviation, WBFH) to carry food for the army. Every WBFH had a password lock. A WBFH would move if and only if the soldier entered the password. Zhuge Liang was always worrying about everything and always did trivial things by himself. Since Ma
Su lost Jieting and was killed by him, he didn't trust anyone's IQ any more. He thought the soldiers might forget the password of WBFHs. So he made two password cards for each WBFH. If the soldier operating a WBFH forgot the password or got killed, the password
still could be regained by those two password cards.

  Once, Sima Yi defeated Zhuge Liang again, and got many WBFHs in the battle field. But he didn't know the passwords. Ma Su's son betrayed Zhuge Liang and came to Sima Yi. He told Sima Yi the way to figure out the password by two cards.He said to Sima Yi:


  "A password card is a square grid consisting of N×N cells.In each cell,there is a number. Two password cards are of the same size. If you overlap them, you get two numbers in each cell. Those two numbers in a cell may be the same or not the same. You can
turn a card by 0 degree, 90 degrees, 180 degrees, or 270 degrees, and then overlap it on another. But flipping is not allowed. The maximum amount of cells which contains two equal numbers after overlapping, is the password. Please note that the two cards must
be totally overlapped. You can't only overlap a part of them."

  Now you should find a way to figure out the password for each WBFH as quickly as possible.
 
Input
  There are several test cases.

  In each test case:

  The first line contains a integer N, meaning that the password card is a N×N grid(0<N<=30).

  Then a N×N matrix follows ,describing a password card. Each element is an integer in a cell.


  Then another N×N matrix follows, describing another password card.

  Those integers are all no less than 0 and less than 300.

  The input ends with N = 0
 
Output
  For each test case, print the password.
 
Sample Input
2
1 2
3 4
5 6
7 8
2
10 20
30 13
90 10
13 21
0
 
Sample Output
0
2
 
Source
 



解题:

    简单模拟下旋转就好。

代码:

#include <iostream>
using namespace std;
int m1[31][31],m2[31][31],m3[31][31],m4[31][31],m5[31][31];
int main()
{
int ans,cnt1,cnt2,cnt3,cnt4;
int n;
while(cin>>n&&n)
{
cnt1=cnt2=cnt3=cnt4=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cin>>m1[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cin>>m2[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
m3[j][i]=m2[i][n-j+1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
m4[j][i]=m3[i][n-j+1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
m5[j][i]=m4[i][n-j+1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(m2[i][j]==m1[i][j])cnt1++;
if(m3[i][j]==m1[i][j])cnt2++;
if(m4[i][j]==m1[i][j])cnt3++;
if(m5[i][j]==m1[i][j])cnt4++;
}
}
ans=cnt1;
if(cnt2>ans)ans=cnt2;
if(cnt3>ans)ans=cnt3;
if(cnt4>ans)ans=cnt4;
cout<<ans<<endl;
}
return 0;
}

HDU 4772 Zhuge Liang&#39;s Password (简单模拟题)的更多相关文章

  1. HDU 4772 Zhuge Liang's Password (2013杭州1003题,水题)

    Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  2. 2019浙大校赛--A--Thanks, TuSimple!(简单模拟题)

    这题前三段都是一堆吹爆赞助商的屁话,正式题目在图片下边,一个简单模拟题. 题目大意: 有n个男生,m个女生在进行舞会,其中一部分男生祥和比自己矮的女生跳舞,一部分男生想和比自己高的女生跳舞,一部分女生 ...

  3. hdu 4739 Zhuge Liang's Mines (简单dfs)

    Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  4. hdu 4739 Zhuge Liang's Mines 随机化

    Zhuge Liang's Mines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  5. HDOJ 4739 Zhuge Liang&#39;s Mines

    Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. HDU 4048 Zhuge Liang's Stone Sentinel Maze

    Zhuge Liang's Stone Sentinel Maze Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/327 ...

  7. HDU 4739 Zhuge Liang's Mines (2013杭州网络赛1002题)

    Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  8. UVa 679 小球下落 简单模拟题,树

    题目大意:给你一个完全二叉树,并且给他们编号,编号规则为左子树为2*k,右子树为2*k+1,每一个节点 上都有一个开关,初始时开关都处于关闭状态,小球碰到节点就会改变该点的开关的状态.然后给你I个小球 ...

  9. POJ 1008 简单模拟题

    e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...

随机推荐

  1. setContentView

    setContentView(R.layout.main)在Android里面,这句话是什么意思? R.layout.main是个布局文件即控件都是如何摆放如何显示的,setContentView就是 ...

  2. postman里面的mockserver使用方法

    转载:http://blog.csdn.net/Cloud_Huan/article/details/78326159 首先说下mockserver是干啥的,从英文翻译理解就是模拟一个服务器,通俗点说 ...

  3. 倍福TwinCAT(贝福Beckhoff)基础教程5.1 TwinCAT-1 获取和设置系统时间

    使用功能块NT_GetTime,NETID填写两个单引号表示本机,START就是一个触发信号,一般的功能块都需要一个上升沿触发执行,最后的输出类型都是让系统自己决定,然后统一把这些变量放到全局变量中( ...

  4. SQL SERVER 使用订阅发布同步数据库(转)

    一.数据库复制涉及  1.发布服务器:  数据的来源服务器,维护源数据,决定哪些数据将被分发,检测哪些数据发生了修改,并将这些信息提交给分发服务器.  2.分发服务器: 分发服务器负责把从发布服务器拿 ...

  5. react-native 扫一扫功能(二维码扫描)功能开发

    1.安装插件 yarn add react-native-smart-barcode 2.关联 react-native link react-native-smart-barcode 3.修改 an ...

  6. 【HTML5】用脚本控制交互元素details元素的使用

    1.源码 <!. Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quo ...

  7. 谈谈PHP网站的防SQL注入

    SQL(Structured Query Language)即结构化查询语言.SQL 注入,就是把 SQL 命令插入到 Web 表单的输入域或页面请求参数的查询字符串中,在 Web表单向 Web 服务 ...

  8. Linux Mint (应用软件— 虚拟机:Virtualbox)

    近期想自己折腾一下Linux系统本身.比方Linux裁减或者移植.裁减或者移植Linux是一件麻烦的事情.而且出错后会影响到当前的系统.怎样才干不影响当前机器上的系统呢,于是便想到了虚拟机.在当前系统 ...

  9. 数据结构之shell排序

    #SIZE  10        //直接插入排序     void insert_sort(){           int i,j;           int array[SIZE+1];   ...

  10. java.long中的类和方法

    java.lang.Character.isUpperCase(char ch) 确定指定的字符是否为大写字符. java.lang.Character.toUpperCase()方法用法转换从Uni ...