zoukankan      html  css  js  c++  java
  • 【习题 4-4 UVA

    【链接】 我是链接,点我呀:)
    【题意】

    在这里输入题意

    【题解】

    绕(x,y,z)三个轴旋转。 枚举x,y,z各4次的结果。 (4次之后能还原。可以方便上一层枚举下一个情况。)

    【代码】

    #include <bits/stdc++.h>
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    using namespace std;
    
    const int N = 12;
    
    char s[N+10];
    char s1[N+5],s2[N+5];
    int ope[3][4]={
        {1,2,6,5},
        {2,4,5,3},
        {1,4,6,3}
    };
    
    void operation(int p){
        char key = s2[ope[p][3]];
        rep2(i,3,1) s2[ope[p][i]] = s2[ope[p][i-1]];
        s2[ope[p][0]] = key;
    }
    
    bool judge(){
        for (int i = 1;i <= 4;i++){
                operation(0);
                for (int j = 1;j <= 4;j++){
                    operation(1);
                    for (int k = 1;k <= 4;k++){
                        operation(2);
                        int ok = 1;
                        rep1(kk,1,6)
                            if (s1[kk]!=s2[kk]){
                                ok = 0;
                                break;
                            }
                        if (ok){
                            return true;
                        }
                    }
                }
            }
        return false;
    }
    
    int main(){
        //freopen("/home/ccy/rush.txt","r",stdin);
       // freopen("/home/ccy/rush_out.txt","w",stdout);
        ios::sync_with_stdio(0),cin.tie(0);
        while (cin >> (s+1)){
            rep1(i,1,6) s1[i] = s[i];
            rep1(i,7,12) s2[i-6] = s[i];
            if (judge()){
                cout<<"TRUE"<<endl;
            }else{
                cout<<"FALSE"<<endl;
            }
        }
        return 0;
    }
    
  • 相关阅读:
    Python-Matplotlib 12 多图figure
    Python-Matplotlib 11 子图-subplot
    Python Day16
    Python Day15
    Python Day13-14
    Python Day12
    Python Day11
    Python Day9-10
    Python Day8
    Python Day8
  • 原文地址:https://www.cnblogs.com/AWCXV/p/9873873.html
Copyright © 2011-2022 走看看