zoukankan      html  css  js  c++  java
  • CCPC A(模拟)

    Secrete Master Plan

    Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
     
     

    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 a 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.

    title

    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 and output

    Sample InputSample Output
    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
    Case #1: POSSIBLE
    Case #2: POSSIBLE
    Case #3: IMPOSSIBLE
    

    题解:要善于把复杂问题简单化,而不是复杂化,自己用数组模拟了半天,好神经;

    代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<algorithm>
     6 using namespace std;
     7 const int INF=0x3f3f3f3f;
     8 int main(){
     9     int a,b,c,d,x,y,z,w;
    10     int T,cnt=0;
    11     scanf("%d",&T);
    12     while(T--){
    13         scanf("%d%d%d%d",&b,&a,&c,&d);
    14         scanf("%d%d%d%d",&y,&x,&z,&w);
    15         bool t1=(a==x&&b==y&&c==z&&d==w);
    16         bool t2=(a==y&&b==z&&c==w&&d==x);
    17         bool t3=(a==z&&b==w&&c==x&&d==y);
    18         bool t4=(a==w&&b==x&&c==y&&d==z);
    19         int flot=0;
    20         if(t1||t2||t3||t4)flot=1;
    21         printf("Case #%d: ",++cnt);
    22         if(flot)puts("POSSIBLE");
    23         else puts("IMPOSSIBLE");
    24     }
    25     return 0;
    26 }
  • 相关阅读:
    C#关系运算符
    C#逻辑运算符
    C#位运算符
    C#赋值运算符
    C#条件运算符(?:)
    C#自增运算符(++)
    C#自减运算符
    C# sizeof运算符
    C# checked运算符
    最大值最小值
  • 原文地址:https://www.cnblogs.com/handsomecui/p/4922956.html
Copyright © 2011-2022 走看看