传送门

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. robotframework接口测试实例

    *** Settings *** Library Collections Library RequestsLibrary *** Test Cases *** test Create Session ...

  2. 洛谷 P1120 小木棍[数据加强版]

    这道题可能是我做过的数据最不水的一道题-- 题目传送门 这题可以说是神剪枝,本身搜索并不算难,但剪枝是真不好想(好吧,我承认我看了题解)-- 剪枝: 用桶来存储木棍 在输入的时候记录下最长的木棍和最短 ...

  3. Java InputStream、String、File相互转化

    String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...

  4. LeetCode(109) Convert Sorted List to Binary Search Tree

    题目 Given a singly linked list where elements are sorted in ascending order, convert it to a height b ...

  5. pandas中Timestamp类用法讲解

    由于网上关于Timestamp类的资料比较少,而且官网上面介绍的很模糊,本文只是对如何创建Timestamp类对象进行简要介绍,详情请读者自行查阅文档. 以下有两种方式可以创建一个Timestamp对 ...

  6. PAT Basic 1050

    1050 螺旋矩阵 本题要求将给定的 N 个正整数按非递增的顺序,填入“螺旋矩阵”.所谓“螺旋矩阵”,是指从左上角第 1 个格子开始,按顺时针螺旋方向填充.要求矩阵的规模为 m 行 n 列,满足条件: ...

  7. PHP 微信分享(及二次分享)

    js部分: <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> &l ...

  8. static对局部变量的作用

    static修饰局部变量: 1,延长局部变量的生命周期到程序技术时,局部变量才会被销毁 2,并没有改变局部变量的作用域 static修饰局部变量的使用场合: 1,如果某个函数的调用频率特别高 2,这个 ...

  9. Python第三方库之openpyxl(4)

    Python第三方库之openpyxl(4) 2D柱状图 在柱状图中,值被绘制成水平条或竖列. 垂直.水平和堆叠柱状图. 注意:以下设置影响不同的图表类型 1.在垂直和水平条形图之间切换,分别设置为c ...

  10. 循环神经网络与LSTM网络

    循环神经网络与LSTM网络 循环神经网络RNN 循环神经网络广泛地应用在序列数据上面,如自然语言,语音和其他的序列数据上.序列数据是有很强的次序关系,比如自然语言.通过深度学习关于序列数据的算法要比两 ...