HDU 5228 ZCC loves straight flush( BestCoder Round #41)
题目链接: pid=5228">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
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.
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.
3
A1 A2 A3 A4 A5
A1 A2 A3 A4 C5
A9 A10 C11 C12 C13
0
1
2
解题:
注意顺子仅仅能连到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)的更多相关文章
- HDU 5228 ZCC loves straight flush 暴力
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5228 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- hdu 5288 ZCC loves straight flush
传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K ...
- 暴力 BestCoder Round #41 1001 ZCC loves straight flush
题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...
- 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 ...
- 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 + ...
- HDU 5805 - NanoApe Loves Sequence (BestCoder Round #86)
先找相邻差值的最大,第二大,第三大 删去端点会减少一个值, 删去其余点会减少两个值,新增一个值,所以新增和现存的最大的值比较一下取最大即可 #include <iostream> #inc ...
- BestCoder Round #41
T1:ZCC loves straight flush(hdu 5228) 题目大意: 给出5张牌,问至少替换多少张牌可以构成同花顺. 题解: 1.直接枚举所有同花顺(枚举花色A-D和最小的数字1-1 ...
- HDU 4876 ZCC loves cards(暴力剪枝)
HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...
- hdu 4873 ZCC Loves Intersection(大数+概率)
pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...
随机推荐
- 機器學習基石 机器学习基石 (Machine Learining Foundations) 作业2 Q16-18 C++实现
大家好,我是Mac Jiang,今天和大家分享Coursera-NTU-機器學習基石(Machine Learning Foundations)-作业2 Q16-18的C++实现.尽管有非常多大神已经 ...
- Pixhawk---基于NSH的Firmware开发与调试
1 相关知识了解 1.1 Nuttx系统 嵌入式实时操作系统(RTOS). 强调标准兼容和小型封装,具有从8位到32位微控制器环境的高度可扩展性.NuttX 主要遵循 Posix 和 ANSI 标 ...
- VB.NET机房收费系统总结
总感觉这次机房收费系统非常有份量,一直没有下手总结,从2014-7-27至2014-9-29.这中间有太多故事和成长.首先说一下两次机房收费系统的不同,它是我们从面向过程向面向对象的一个转变.在.NE ...
- 【转】iOS多语言本地化(国际化)设置
原文网址:http://www.jianshu.com/p/2b7743ae9c90 讨论的iOS应用中的多语言设置,Ok 一般是两种情况: 1.根据当前设备语言自动切换显示 2.在应用中可进行语言设 ...
- java生成6位随机数的5种方法
转自:https://blog.csdn.net/u012491783/article/details/76862526/
- 达夫设备之js
最近阅读<高性能JavaScript>时,在书中的“达夫设备“ . 对此,有些感悟,同时有些疑问,希望看到的朋友,能帮忙解释下,在此先提前感谢了. 1. 先说自己的理解吧: ”达夫设备“的 ...
- 防范CSRF(二)
在防范CSRF(一)中使用的是微软默认的设置.在信息安全中默认的往往是最危险的.因此可以考虑更改cookie中默认的名字. 更改默认操作在Global.asax中的Application_Start使 ...
- Caffe CommonLayer分析
Caffe CommonLayer分析 \(Caffe\)中包含了很多通用的功能层,包含了\(concat\),\(slice\),\(split\),\(crop\),\(flip\),\(scal ...
- MySQL---Day2
-- 转载:http://www.cnblogs.com/yuanchenqi/articles/6357507.html CREATE TABLE employee1( id TINYINT PRI ...
- HDU 1061 Rightmost Digit( 快速幂水 )
链接:传送门 题意:求 N^N 的个位 思路:快速幂水题 /********************************************************************** ...