zoukankan      html  css  js  c++  java
  • HDU 5228 ZCC loves straight flush( BestCoder Round #41)

    题目链接:ZCC loves straight flush


    题面:

    ZCC loves straight flush

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
    Total Submission(s): 827    Accepted Submission(s): 340


    Problem Description
    After losing all his chips when playing Texas Hold'em with Fsygd on the way to ZJOI2015, ZCC has just learned a black technology. Now ZCC is able to change all cards as he wants during the game. ZCC wants to get a Straight Flush by changing as few cards as possible.

    We call a five-card hand a Straight Flush when all five cards are consecutive and of the same suit. You are given a five-card hand. Please tell ZCC how many cards must be changed so as to get a Straight Flush.
      
    Cards are represented by a letter('A', 'B', 'C', 'D') which denotes the suit and a number('1', '2', , '13') which denotes the rank.
      
    Note that number '1' represents ace which is the largest actually. "1 2 3 4 5" and "10 11 12 13 1" are both considered to be consecutive while "11 12 13 1 2" is not.
     

    Input
    First line contains a single integer T(T=1000) which denotes the number of test cases.
    For each test case, there are five short strings which denote the cards in a single line. It's guaranteed that all five cards are different.
     

    Output
    For each test case, output a single line which is the answer.
     

    Sample Input
    3 A1 A2 A3 A4 A5 A1 A2 A3 A4 C5 A9 A10 C11 C12 C13
     

    Sample Output
    0 1 2
     

    Source

    解题:

    注意顺子仅仅能连到A。


    代码:

    #include <iostream>
    #include <cmath>
    #include <cstring>
    using namespace std;
    bool status[4][15];
    int main()
    {
        int t,n,root;
        cin>>t;
        char c;
        int tmp,cnt,maxx;
        while(t--)
        {
           memset(status,0,sizeof(status));
           for(int i=0;i<5;i++)
           {
                cin>>c>>tmp;
                status[c-'A'][tmp]=1;
                 if(tmp==1)status[c-'A'][14]=1;
           }
           maxx=0;
           for(int i=0;i<4;i++)
           {
                for(int j=1;j<=10;j++)
                {
                    cnt=0;
                if(status[i][j])cnt++;
                  if(status[i][j+1])cnt++;
                  if(status[i][j+2])cnt++;
                  if(status[i][j+3])cnt++;
                  if(status[i][j+4])cnt++;
                  if(cnt>maxx)
                    maxx=cnt;
             }
           }
           cout<<5-maxx<<endl;
        }
        return 0;
    }
    
    



  • 相关阅读:
    WCF基础 (续 更多关于配置文件的内容)
    WCF基础 (续 暴露元数据交换节点)
    简单的asp.net文件上传类
    根据年份月份,获得此月份的所有日期[转]
    JS 设为首页/加入收藏
    WCF基础 (续 使用代码生成WCF服务)
    WPF自定义标题栏——窗口移动和按钮状态转换[转]
    WCF元数据交换
    WCF基础 (续 为一个ASMX服务实现一个WCF客户端) 完结
    WCF基础 (续 通过代码和配置文件写一个WCF服务)
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/7041319.html
Copyright © 2011-2022 走看看