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 ...
随机推荐
- USACO 1.2 Transformations (模拟)
模拟题目,依照题目给定的要求变换图形就可以,变换的优先级依次减小. 这个题目我写的非常乱.只是最还还是勉强能够执行 /* ID:twd30651 PROG:transform LANG:C++ */ ...
- node generator 模仿co
exports.run = function(fn ){ return function(onDone){ function thunk(tfn , ctx){ return function(sql ...
- 【iOS开发-68】APP下载案例:利用tableView自带的cell布局+缓存池cell复用时注意button状态的检查
(1)效果 (2)源码与资源下载 http://pan.baidu.com/s/1pJLo2PP (3)总结 --核心是利用UITableView里面自带的cell来制作样式同样的cell. 与之对应 ...
- Visual studio 编译时copy文件、文件夹
项目属性--生成事件 添加命令 xcopy /y /d "$(SolutionDir)Dll\Linphone\*.dll" "$(TargetDir)\Linphone ...
- thinkPHP 空模块和空操作、前置操作和后置操作 具体介绍(十四)
本章节:介绍 TP 空模块和空操作.前置操作和后置操作 具体介绍 一.空模块和空操作 1.空操作 function _empty($name){ $this->show("$name ...
- 最长公共子序列(Swift版本)
class Mark { var count: Int var type: Int init(count: Int, type: Int) { self ...
- c7---函数
// // main.c // 函数练习 // // Created by xiaomage on 15/6/7. // Copyright (c) 2015年 xiaomage. All right ...
- Extjs 常见错误
http://blog.csdn.net/lc448986375/article/details/8082014
- 前端将图片二进制流显示在html端
工作中碰到的问题,在处理接口返回的验证码图片时,由于返回的是encode编码代码,在js端获取到数据之后,通过函数encodeURI()来进行解码,之后可以通过在src中设置来实现图片显示:
- 洛谷P3327 [SDOI2015]约数个数和(莫比乌斯反演)
题目描述 设d(x)为x的约数个数,给定N.M,求 \sum^N_{i=1}\sum^M_{j=1}d(ij)∑i=1N∑j=1Md(ij) 输入输出格式 输入格式: 输入文件包含多组测试数据.第 ...