题目链接:

pid=5228">ZCC loves straight flush

pid=5228">题面:

pid=5228">

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)的更多相关文章

  1. HDU 5228 ZCC loves straight flush 暴力

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

  2. hdu 5288 ZCC loves straight flush

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

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

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

  4. hdu 5195 DZY Loves Topological Sorting BestCoder Round #35 1002 [ 拓扑排序 + 优先队列 || 线段树 ]

    传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131 ...

  5. HDU 5806 - NanoApe Loves Sequence Ⅱ (BestCoder Round #86)

    若 [i, j] 满足, 则 [i, j+1], [i, j+2]...[i,n]均满足 故设当前区间里个数为size, 对于每个 i ,找到刚满足 size == k 的 [i, j], ans + ...

  6. HDU 5805 - NanoApe Loves Sequence (BestCoder Round #86)

    先找相邻差值的最大,第二大,第三大 删去端点会减少一个值, 删去其余点会减少两个值,新增一个值,所以新增和现存的最大的值比较一下取最大即可 #include <iostream> #inc ...

  7. BestCoder Round #41

    T1:ZCC loves straight flush(hdu 5228) 题目大意: 给出5张牌,问至少替换多少张牌可以构成同花顺. 题解: 1.直接枚举所有同花顺(枚举花色A-D和最小的数字1-1 ...

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

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

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

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

随机推荐

  1. 普通androidproject转换为C/C++project之后,再还原成androidproject的解决方式

    我们在调试android程序时,可能会把androidproject转换成C/C++project,或者Add Native Support.可是,我们怎么把C/C++project还原成普通的and ...

  2. Registry Connect failed,Windows服务诊断

    Message:Connection failed for 192.168.32.38_e-futrueserer. Details:Windows Registry Datasource: Regi ...

  3. gdb help all 帮助信息

    Command class: aliases ni -- Step one instruction rc -- Continue program being debugged but run it i ...

  4. Python 加载数据

    1. numpy data = np.loadtxt('./data/txtdata.csv') ⇒ data 是 numpy.ndarray 类型

  5. SPOJ COT2 Count on a tree II (树上莫队)

    题目链接:http://www.spoj.com/problems/COT2/ 参考博客:http://www.cnblogs.com/xcw0754/p/4763804.html上面这个人推导部分写 ...

  6. PHP 上传文件到其他服务器

    PHP 上传文件到其他服务器 标签(空格分隔): 安装Guzzle类库 **guzzle** 是发送网络请求的类库 composer安装:**composer require guzzlehttp/g ...

  7. CentOS 6.7操作系统安装

    如果由于是显卡驱动不兼容的话,在选择安装界面按tab键,进入命令行,然后在命令行后加上 nodmraid 关键字回车开始安装. 接下来选择hard driver   选择最后一个分区进行系统安装,然后 ...

  8. 备份IIS

    备份IIS,这里实质指的是备份IIS配置.如果要备份IIS部署的网站的话,直接Copy目录就行了. 备份IIS配置其实和备份系统含义差不多,为了方便系统或者IIS出现故障后能够及时恢复到某节点上,所以 ...

  9. Upload图片-单张

    上传图片全不怕,轻松实现图片上传, 可以实现显示缩略图喔: 后台代码: protected void btnpic_upload_Click(object sender, EventArgs e) { ...

  10. line-height与间距总总

    一点说明(个人吐槽,可以略过) 之所以想写这篇文章,是因为自己工作的经验总结.以前的页面编写极度不注重间距大小,特别是行级元素间距.认为只要差不多好就行了,没必要花那么大的精力去抠几px的小细节.事实 ...