zoukankan      html  css  js  c++  java
  • ACM学习历程—UESTC 1215 Secrete Master Plan(矩阵旋转)(2015CCPC A)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1215

    题目大意就是问一个2*2的矩阵能否通过旋转得到另一个。

    代码:

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <set>
    #include <map>
    #include <queue>
    #include <string>
    #define LL long long
    
    using namespace std;
    
    struct Matrix
    {
        int v[2][2];
    
        void get()
        {
            for (int i = 0; i < 2; ++i)
                for (int j = 0; j < 2; ++j)
                    scanf("%d", &v[i][j]);
        }
    
        void turn()
        {
            swap(v[0][0], v[0][1]);
            swap(v[0][0], v[1][1]);
            swap(v[0][0], v[1][0]);
        }
    
        bool operator==(const Matrix x) const
        {
            for (int i = 0; i < 2; ++i)
                for (int j = 0; j < 2; ++j)
                    if (v[i][j] != x.v[i][j])
                        return false;
            return true;
        }
    }a, b;
    
    void input()
    {
        a.get();
        b.get();
        bool flag = false;
        for (int i = 0; i < 4; ++i)
        {
            b.turn();
            if (a == b)
            {
                flag = true;
                break;
            }
        }
        if (flag) printf("POSSIBLE
    ");
        else printf("IMPOSSIBLE
    ");
    }
    
    int main()
    {
        //freopen("test.in", "r", stdin);
        int T;
        scanf("%d", &T);
        for (int times = 1; times <= T; ++times)
        {
            printf("Case #%d: ", times);
            input();
        }
        return 0;
    }
    View Code
  • 相关阅读:
    使用fiddler2抓取手机发出的请求信息
    HTML转义字符集合
    spm3安装和使用
    JSP
    Servlet
    Struts2
    java多线程-消费者和生产者模式
    java异常处理机制(try-catch-finally)
    java内部类
    java上转型和下转型(对象的多态性)
  • 原文地址:https://www.cnblogs.com/andyqsmart/p/4997315.html
Copyright © 2011-2022 走看看