• CH0802 占卜DIY


    模拟

    没怎么看题。。直接deque模拟水过了。。
    但是后来回过头看了下题意。。如果再次拿到正面朝上的牌,应该是废操作。。可能是数据太水了。。。

    #include <bits/stdc++.h>
    #define INF 0x3f3f3f3f
    #define full(a, b) memset(a, b, sizeof a)
    using namespace std;
    typedef long long ll;
    inline int lowbit(int x){ return x & (-x); }
    inline int read(){
        int X = 0, w = 0; char ch = 0;
        while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
        while(isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
        return w ? -X : X;
    }
    inline int gcd(int a, int b){ return a % b ? gcd(b, a % b) : b; }
    inline int lcm(int a, int b){ return a / gcd(a, b) * b; }
    template<typename T>
    inline T max(T x, T y, T z){ return max(max(x, y), z); }
    template<typename T>
    inline T min(T x, T y, T z){ return min(min(x, y), z); }
    template<typename A, typename B, typename C>
    inline A fpow(A x, B p, C lyd){
        A ans = 1;
        for(; p; p >>= 1, x = 1LL * x * x % lyd)if(p & 1)ans = 1LL * x * ans % lyd;
        return ans;
    }
    deque<char> q[13];
    map<char, int> m;
    int vis[14];
    char s[] = {'A', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'J', 'Q', 'K'};
    
    void init(){
        m['A'] = 0, m['2'] = 1, m['3'] = 2, m['4'] = 3;
        m['5'] = 4, m['6'] = 5, m['7'] = 6, m['8'] = 7;
        m['9'] = 8, m['0'] = 9, m['J'] = 10, m['Q'] = 11, m['K'] = 12;
    }
    
    int main(){
    
        int ans = 0;
        init();
        for(int i = 0; i < 13; i ++){
            for(int j = 0; j < 4; j ++){
                char ch; cin >> ch;
                q[i].push_back(ch);
            }
        }
        int tmp = 0, cur = m[q[12].front()];
        q[12].pop_front();
        while(tmp < 4){
            if(cur == 12){
                tmp ++, cur = m[q[12].front()], q[12].pop_front();
                continue;
            }
            vis[cur] ++;
            if(vis[cur] == 4) ans ++;
            int temp = cur;
            cur = m[q[temp].back()], q[temp].pop_back(), q[temp].push_front(s[temp]);
        }
        printf("%d
    ", ans);
        return 0;
    }
    
  • 相关阅读:
    VM12+CentOS6.8安装VM tools
    PHP关联数组按某一value值排序
    命名规范
    JavaScript中的函数
    JavaScript中的for循环语句
    JavaScript中的判断和循环
    Javascript运算符的分类
    Html中的JavaScript
    【逆战】HTML5新语义化标签 (二)
    【逆战】HTML5新语义化标签 (一)
  • 原文地址:https://www.cnblogs.com/onionQAQ/p/10623719.html
Copyright © 2020-2023  润新知