zoukankan      html  css  js  c++  java
  • tyvj1424 占卜DIY

    大水题一道。纯模拟代码才60行。

     1 #include <cstdio>
     2 using namespace std;
     3 
     4 int pile[14][5], open[13];
     5 
     6 inline bool ban(char c) {
     7     if(c <= '9' && c >= '0') return 0;
     8     if(c == 'A' || c == 'J' || c == 'Q' || c == 'K') {
     9         return 0;
    10     }
    11     return 1;
    12 }
    13 
    14 inline int get(char c) {
    15     if(c == 'A') {
    16         return 1;
    17     }
    18     if(c == 'J') {
    19         return 11;
    20     }
    21     if(c == 'Q') {
    22         return 12;
    23     }
    24     if(c == 'K') {
    25         return 13;
    26     }
    27     if(c == '0') {
    28         return 10;
    29     }
    30     return c - '0';
    31 }
    32 
    33 int main() {
    34     for(int i = 1; i <= 13; i++) {
    35         for(int j = 4; j >= 1; j--) {
    36             char c = getchar();
    37             while(ban(c)) {
    38                 c = getchar();
    39             }
    40             pile[i][j] = get(c);
    41         }
    42     }
    43     pile[13][0] = 4;
    44     while(pile[13][0]) {
    45         int k = pile[13][pile[13][0]];
    46         pile[13][0]--;
    47         while(k != 13) {
    48             open[k]++;
    49             pile[k][0]++;
    50             k = pile[k][pile[k][0]];
    51         }
    52     }
    53     int ans = 0;
    54     for(int i = 1; i <= 12; i++) {
    55         ans += (open[i] == 4);
    56     }
    57     printf("%d", ans);
    58     return 0;
    59 }
    AC代码
  • 相关阅读:
    关于代码风格
    python笔记-glob模块
    python笔记-mysql安装与配置
    python笔记-shutil模块
    python笔记-os模块
    python笔记-内存分析
    python笔记-装饰器
    python笔记-正则表达式
    python笔记-迭代器-生成器-对象生成式
    python笔记-模块和包
  • 原文地址:https://www.cnblogs.com/huyufeifei/p/9019162.html
Copyright © 2011-2022 走看看