传送门

ZCC loves straight flush

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

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
 
Recommend
hujie   |   We have carefully selected several similar problems for you:  5639 5638 5637 5636 5635 
 
 
思路:
一开始没注意到suit 只能是啊a,b,c,d, 也以为卡片的顺序不能变,,又把问题想复杂了。
其实,只要 哈希花色和数字,然后暴力枚举
 
 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <cctype>
#include <vector>
#include <cmath>
#include <map>
#include <queue> #define ll long long using namespace std; int T;
int mi;
char s[];
int t[][]; void solve()
{
int i,j,k;
int p;
for(i = ;i < ;i++){
for(j = ;j <= ;j++ ){
p = ;
for(k = ;k <= ;k++){
if(t[i][ (j+k-)%+ ]){
p++;
}
}
mi = min(mi, - p);
}
}
} int main()
{
//freopen("in.txt","r",stdin);
scanf("%d",&T);
for(int ccnt=;ccnt<=T;ccnt++){
//while(scanf("%d%s%s",&n,a,b)!=EOF){
mi = ;
int i;
int v;
memset(t,,sizeof(t));
for(i = ;i <= ;i++){
scanf("%s",s);
v = s[] - '';
if(strlen(s) == ){
v*=;
v+=s[] - '';
}
t[ s[] - 'A' ][ v ] = ;
}
solve();
printf("%d\n",mi);
}
return ;
}

hdu 5288 ZCC loves straight flush的更多相关文章

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

    题目链接:pid=5228">ZCC loves straight flush pid=5228">题面: pid=5228"> ZCC loves s ...

  2. HDU 5228 ZCC loves straight flush 暴力

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5228 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  3. 暴力 BestCoder Round #41 1001 ZCC loves straight flush

    题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...

  4. HDU 4876 ZCC loves cards(暴力剪枝)

    HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...

  5. hdu 4873 ZCC Loves Intersection(大数+概率)

    pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...

  6. hdu 4876 ZCC loves cards(暴力)

    题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...

  7. HDU 4873 ZCC Loves Intersection(可能性)

    HDU 4873 ZCC Loves Intersection pid=4873" target="_blank" style="">题目链接 ...

  8. hdu 4882 ZCC Loves Codefires(数学题+贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...

  9. HDU 4882 ZCC Loves Codefires (贪心)

    ZCC Loves Codefires 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/B Description Though ...

随机推荐

  1. 贴一发STL源码

    int my_lower_bound(int size, long long key){    int first = 0, middle;    int half, len;    len = si ...

  2. hdu 1181 深搜

    中文题 深搜 许久没写鸟,卡在输入问题上... #include <iostream> #include <string> using namespace std; bool ...

  3. socket的BeginConnect(EndPoint remoteEP,AsyncCallback callback,objcet state);个人理解

    1.socket.BeginConnect(); 其中的三个参数值EndPoint remoteEP,这个是用来指定连接的socket服务器的的地址 socket参数表 EndPoint remote ...

  4. Oracle 回顾

    Oracle 函数 日期函数: 1.sysdate--查询当前日期 select sysdate from dual;  --查询当前日期 2.months_between--返回两个日期之间的月份差 ...

  5. iPhone Scrollbars with iScroll

    Since we've had web browsers and JavaScript, we've been intent on replacing native browser functiona ...

  6. JsonUtils工具类

    public class JsonUtils { public static void printTimeObject(Object obj, HttpServletResponse response ...

  7. centos7 samba配置完成后不管怎么登陆都会显示密码错误的解决方案

    添加系统用户 useradd samba 添加samba用户 smbpasswd -a samba 激活samba用户 smbpasswd -e samba 1.win+r运行secpol.msc打开 ...

  8. Android Studio问题记录

    1>Android Studio中module是什么,? 答:Android Studio是基于intellij,跟eclipse不太一样.对应关系如下: intellij的project -- ...

  9. Centos7下安装iptables防火墙

    说明:centos7默认使用的firewalld防火墙,由于习惯使用iptables做防火墙,所以在安装好centos7系统后,会将默认的firewall关闭,并另安装iptables进行防火墙规则设 ...

  10. AHB2reg接口转换

    assign mcu_xxx_addr = (rd_after_wr_reg || reg_valid_write_trans) ? haddr_reg[ADDR_WIDTH+:] : haddr[A ...