HDOJ5540 Secrete Master Plan

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

题目大意:给一个两个2*2的矩阵,第二个矩阵能不能通过旋转得到第一个矩阵

题目思路:模拟

 1 #include <stdio.h>
 2 #include <iostream>
 3 using namespace std;
 4 int ori[5][5];
 5 int par[5][5];
 6 int temp[5][5];
 7 void solve(int T){
 8     for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) scanf("%d",&ori[i][j]);
 9     for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) scanf("%d",&par[i][j]);
10     bool flag=false;
11     for(int u=1;u<=4;u++){
12         temp[1][1]=par[1][2];
13         temp[1][2]=par[2][2];
14         temp[2][1]=par[1][1];
15         temp[2][2]=par[2][1];
16         temp[2][2]=par[2][1];
17         bool tmp=true;
18         for(int x=1;x<=2;x++){
19             for(int y=1;y<=2;y++){
20                 if(ori[x][y]!=temp[x][y]){
21                     tmp=false;
22                     break;
23                 }
24             }
25             if(!tmp) break;
26         }
27         flag|=tmp;
28         if(flag) break;
29         for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) par[i][j]=temp[i][j];
30     }
31     printf("Case #%d: ",T);
32     if(flag) printf("POSSIBLE
");
33     else printf("IMPOSSIBLE
");
34     return ;
35 }
36 int main(){
37     int T;
38     scanf("%d",&T);
39     for(int i=1;i<=T;i++) solve(i);
40 }
原文地址:https://www.cnblogs.com/as3asddd/p/6071926.html