诸葛亮密码的破解方法有哪些?

2026-04-02 02:191阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计455个文字,预计阅读时间需要2分钟。

诸葛亮密码的破解方法有哪些?

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

题目:给定一个矩阵a和b,问a和b最多有几个元素相同,b可以旋转角度。

诸葛亮密码的破解方法有哪些?

解析:水题,直接做+


题目链接:​​acm.hdu.edu.cn/showproblem.php?pid=4772​​​
题意:给你一个n,再给你两个nxn的矩阵a,b,问你a,b最多有几个元素相同,b可以旋转角度
解析:水题,直接做

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <stack>
#include <map>
using namespace std;
const int maxn = 50;
int a[maxn][maxn];
int b[maxn][maxn];
int main()
{
int n;
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]);
int ans = 0;
int tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[i][j])
tmp++;
}
}
ans = max(ans,tmp);
tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[j][n-1-i])
tmp++;
//printf("%d ",b[j][n-1-i]);
}
//puts("");
}
ans = max(ans,tmp);
tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[n-1-i][n-1-j])
tmp++;
//printf("%d ",b[n-1-i][n-1-j]);
}
//puts("");
}
ans = max(ans,tmp);
tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[n-1-j][i])
tmp++;
//printf("%d ",b[n-1-j][i]);
}
//puts("");
}
ans = max(ans,tmp);
printf("%d\n",ans);
}
return 0;
}


本文共计455个文字,预计阅读时间需要2分钟。

诸葛亮密码的破解方法有哪些?

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

题目:给定一个矩阵a和b,问a和b最多有几个元素相同,b可以旋转角度。

诸葛亮密码的破解方法有哪些?

解析:水题,直接做+


题目链接:​​acm.hdu.edu.cn/showproblem.php?pid=4772​​​
题意:给你一个n,再给你两个nxn的矩阵a,b,问你a,b最多有几个元素相同,b可以旋转角度
解析:水题,直接做

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <stack>
#include <map>
using namespace std;
const int maxn = 50;
int a[maxn][maxn];
int b[maxn][maxn];
int main()
{
int n;
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]);
int ans = 0;
int tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[i][j])
tmp++;
}
}
ans = max(ans,tmp);
tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[j][n-1-i])
tmp++;
//printf("%d ",b[j][n-1-i]);
}
//puts("");
}
ans = max(ans,tmp);
tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[n-1-i][n-1-j])
tmp++;
//printf("%d ",b[n-1-i][n-1-j]);
}
//puts("");
}
ans = max(ans,tmp);
tmp = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==b[n-1-j][i])
tmp++;
//printf("%d ",b[n-1-j][i]);
}
//puts("");
}
ans = max(ans,tmp);
printf("%d\n",ans);
}
return 0;
}