zoukankan      html  css  js  c++  java
  • HDU-5540 Secrete Master Plan

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
    Total Submission(s): 801    Accepted Submission(s): 470

    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 matrix, but Fei didn't know the correct direction to hold the sheet. What a pity!

    Given two secrete master plans. The first one is the master's original plan. The second one is the plan opened by Fei. As KongMing had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.

     
    Input
    The first line of the input gives the number of test cases, T(1T104)T test cases follow. Each test case contains 4 lines. Each line contains two integers ai0 and ai1 (1ai0,ai1100). The first two lines stands for the original plan, the 3rd and 4th line stands for the plan Fei opened.
     
    Output
    For each test case, output one line containing "Case #x: y", where x is the test case number
    (starting from 1) and y is either "POSSIBLE" or "IMPOSSIBLE" (quotes for clarity).
     
    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

    题意:

    求所给矩阵能否经过旋转得到下一个矩阵。

    就对比顺时针前后两元素是否相等即可。

    附AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main(){
     5     int t;
     6     cin>>t;
     7     int ans=1;
     8     while(t--){
     9         int a1,b1,c1,d1,a2,b2,c2,d2;
    10         cin>>a1>>b1>>c1>>d1>>a2>>b2>>c2>>d2;
    11         if(a2==a1&&b1==b2&&c1==c2){
    12             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
    13             continue;
    14         }
    15         if(b2==a1&&a2==c1&&d2==b1){
    16             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
    17             continue;
    18         }
    19         if(c2==a1&&d2==c1&&a2==b1){
    20             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
    21             continue;
    22         }
    23         if(d2==a1&&c2==b1&&b2==c1){
    24             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
    25             continue;
    26         }
    27         cout<<"Case #"<<ans++<<": IMPOSSIBLE"<<endl;
    28     }
    29     return 0;
    30 }
  • 相关阅读:
    staticmethod & classmethod
    stanford Python
    LD_LIBRARY_PATH
    Centos7.2 errors
    theano profile
    电梯开关量GPIO配置记录
    定时器配置 中断配置 GPIO
    电梯开发进度贴
    Makefile编写学习摘要
    数据挖掘聚类算法--Kmeans
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/5873663.html
Copyright © 2011-2022 走看看