HDU 5228 ZCC loves straight flush( BestCoder Round #41)

原创 2015年07月08日 09:12:10

题目链接: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;
}




版权声明:欢迎交流!

hdu 5228 ZCC loves straight flush && BestCoder Round #41 1001

在前往ZJOI2015一试的路上,ZCC在同Fsygd打德州扑克时输光了所有的筹码。不过ZCC最近学会了一些黑技术。现在,他能够在游戏过程中更换任何他想要更换的牌。ZCC想要通过更换尽量少的牌得到同花...

HDU 5228 ZCC loves straight flush

题意:(直接看的BC上的中文题,其实说实话,这个是不好的,希望大家不要这样。)就是让你把5个输入的数编程同花顺的最小步数。其中牌只有4中花色,用A、B、C、D表示,然后值用1-13表示。 特殊的:A...

hdu5228 ZCC loves straight flush(模拟)

ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (...

hdu 5230 ZCC loves hacking && BestCoder Round #41 1003

题意: Codefires round马上就要结束了!ZCC已经通过做题得到了C(0≤C≤106)分。但他惊讶地发现,房间里的其他选手也都解决了最难的题。ZCC根据经验断定大多数的选手都会FST...

hdu 5229 ZCC loves strings && BestCoder Round #41 1002

ZCC有N个字符串,他正在和Miss G.用这N个字符串玩一个小游戏。ZCC会从这N个串中等概率随机选两个字符串(不可以是同一个)。然后,ZCC和Miss G.轮流操作。Miss G.总是先操作的。在...

HDU5806 NanoApe Loves Sequence Ⅱ BestCoder Round #86 two-pointer

NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K (J...
  • kyoma
  • kyoma
  • 2016年08月09日 10:00
  • 257

二指针_____NanoApe Loves Sequence II(hdu 5806 BestCoder Round #86)

问题描述 退役狗 NanoApe 滚回去学文化课啦! 在数学课上,NanoApe 心痒痒又玩起了数列。他在纸上随便写了一个长度为 nn 的数列,他又根据心情写下了一个数 mm。 他想知道这个数列中...

HDU 5273 Dylans loves sequence——BestCoder Round #45(DP or 树状数组)

HDU 5273 Dylans loves sequence——BestCoder Round #45(DP or 树状数组)

【HDU5648 BestCoder Round 76 (div1)C】【打表or数位DP】DZY Loves Math nm范围内i和j i或j的gcd之和

DZY Loves Math    Accepts: 20    Submissions: 78  Time Limit: 10000/5000 MS (Java/Others)   ...

HDU-5194-DZY Loves Balls(BestCoder Round # 35 )

DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:HDU 5228 ZCC loves straight flush( BestCoder Round #41)
举报原因:
原因补充:

(最多只允许输入30个字)