码迷,mamicode.com
首页 > 其他好文 > 详细

CH0802 占卜DIY

时间:2019-03-29 21:07:04      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:map   dig   tmp   eof   its   getc   while   clu   push   

模拟

没怎么看题。。直接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\n", ans);
    return 0;
}

CH0802 占卜DIY

标签:map   dig   tmp   eof   its   getc   while   clu   push   

原文地址:https://www.cnblogs.com/onionQAQ/p/10623719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!