占卜DIY(模拟)

题面:占卜DIY
思路:

没什么好说的,就纯粹的模拟。
注意: 0 0 0 代表的是 10 10 10

代码:
#include <bits/stdc++.h>
#define sc scanf
#define pf printf
using namespace std;
deque<string> q[20];
map<string, int> vis;

int check(string x)
{
    if(x == "A")  return 1;
    if(x == "J")  return 11;
    if(x == "Q")  return 12;
    if(x == "K")  return 13;
    char y = x[0];
    if(y == '0')  return 10;
    return y - '0';
}

int main()
{
    for(int i = 1; i <= 13; i++) {
        for(int j = 0; j < 4; j++) {
            string c;
            cin >> c;
            q[i].push_back(c);
        }
    }
    while(true) {
        if(vis["K"] == 4 || q[13].empty())  break;
        auto t = q[13].front();
        q[13].pop_front();
        vis[t]++;
        if(t == "K")  continue;
        bool flag = true;
        while(flag) {
            int k = check(t);
            q[k].push_front(t);
            t = q[k].back();
            q[k].pop_back();
            vis[t]++;
            if(t == "K") {flag = false; continue;}
        }
        if(!flag)  continue;
    }
    int cnt = 0;
    vis.erase("K");
    for(map<string, int>::iterator it = vis.begin(); it != vis.end(); ++it)
        if(it->second == 4)  cnt++;
    pf("%d\n", cnt);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值