zoukankan      html  css  js  c++  java
  • ACM Secrete Master Plan

    Problem Description
    Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, when Fei opened the pocket he found there are only four numbers written in dots on a piece of sheet. The numbers form 2×2



     
    Input
    The first line of the input gives the number of test cases, T(1T104)Tai0ai11ai0,ai11003rd4th
     
    Output
    For each test case, output one line containing "Case #x: y", where x is the test case number
    (starting from 1) and y
     
    Sample Input
    4
    1 2
    3 4
    1 2
    3 4
     
    1 2
    3 4
    3 1
    4 2
     
    1 2
    3 4
    3 2
    4 1
     
    1 2
    3 4
    4 3
    2 1
     
    Sample Output
    Case #1: POSSIBLE
    Case #2: POSSIBLE
    Case #3: IMPOSSIBLE
    Case #4: POSSIBLE
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 /*
     4     方块旋转,两个矩形,如果能够通过旋转使两个一样则输出 possible
     5      否则则输出impossible 
     6 */
     7 int  A[5][5],B[5][5];  //矩阵A,矩阵B 
     8 //判断现两个矩形是否一样 
     9 bool Judge()       
    10 {
    11     for(int i = 0; i < 2; i++)
    12         for(int j = 0; j < 2; j++)
    13             if(A[i][j] != B[i][j])
    14                 return false;
    15     return true;
    16 }
    17 //将一个矩形进行旋转,顺时针旋转,
    18 //破点:将[0][0]先后进行向左、斜方向、向下交换 
    19 void Swap()
    20 {
    21     swap(A[0][0],A[0][1]);
    22     swap(A[0][0],A[1][1]);
    23     swap(A[0][0],A[1][0]);    
    24 }
    25 //通过旋转四次进行判定是否满足题意 
    26 bool Solve()
    27 {
    28     for(int i = 0; i < 4; i++)
    29     {
    30         if(Judge())
    31             return true;
    32         else
    33             Swap();
    34     }
    35     return false;
    36 }
    37 
    38 int main()
    39 {
    40     int T,n;
    41     while(~scanf("%d",&T))
    42     {
    43         for(int p= 1; p <= T; p++)
    44         {
    45             
    46             scanf("%d %d %d %d",&A[0][0],&A[0][1],&A[1][0],&A[1][1]);
    47             scanf("%d %d %d %d",&B[0][0],&B[0][1],&B[1][0],&B[1][1]);
    48             printf("Case #%d: ",p);
    49             if(Solve())
    50             {
    51                 printf("POSSIBLE
    ");
    52             }
    53             else
    54             {
    55                 printf("IMPOSSIBLE
    ");    
    56             }
    57             
    58             
    59         }
    60     }
    61     return 0;
    62  } 
  • 相关阅读:
    代码扫描工具
    事务注解加在Controller 和 Service上有哪些区别
    什么是嵌套事务
    配置工程日志
    利用mkvirtualenv工具搭建python2和python3环境
    python接口自动化1-发送get请求
    面试题:使用存储过程造10w条测试数据,数据不重复
    python测试开发
    接口自动化测试持续集成+postman+newman+git+jenkins+钉钉
    app专项测试
  • 原文地址:https://www.cnblogs.com/jj81/p/7636885.html
Copyright © 2011-2022 走看看