传送门

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, 也以为卡片的顺序不能变,,又把问题想复杂了。
其实,只要 哈希花色和数字,然后暴力枚举
 
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <stack>
  6. #include <cctype>
  7. #include <vector>
  8. #include <cmath>
  9. #include <map>
  10. #include <queue>
  11.  
  12. #define ll long long
  13.  
  14. using namespace std;
  15.  
  16. int T;
  17. int mi;
  18. char s[];
  19. int t[][];
  20.  
  21. void solve()
  22. {
  23. int i,j,k;
  24. int p;
  25. for(i = ;i < ;i++){
  26. for(j = ;j <= ;j++ ){
  27. p = ;
  28. for(k = ;k <= ;k++){
  29. if(t[i][ (j+k-)%+ ]){
  30. p++;
  31. }
  32. }
  33. mi = min(mi, - p);
  34. }
  35. }
  36. }
  37.  
  38. int main()
  39. {
  40. //freopen("in.txt","r",stdin);
  41. scanf("%d",&T);
  42. for(int ccnt=;ccnt<=T;ccnt++){
  43. //while(scanf("%d%s%s",&n,a,b)!=EOF){
  44. mi = ;
  45. int i;
  46. int v;
  47. memset(t,,sizeof(t));
  48. for(i = ;i <= ;i++){
  49. scanf("%s",s);
  50. v = s[] - '';
  51. if(strlen(s) == ){
  52. v*=;
  53. v+=s[] - '';
  54. }
  55. t[ s[] - 'A' ][ v ] = ;
  56. }
  57. solve();
  58. printf("%d\n",mi);
  59. }
  60. return ;
  61. }

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. python简单爬虫爬取百度百科python词条网页

    目标分析:目标:百度百科python词条相关词条网页 - 标题和简介 入口页:https://baike.baidu.com/item/Python/407313 URL格式: - 词条页面URL:/ ...

  2. Asp.Net Core 入门(八)—— Taghelper

    Taghelper是一个服务端的组件,可以在Razor文件中创建和渲染HTML元素,类似于我们在Asp.Net MVC中使用的Html Taghelper.Asp.Net Core MVC内置的Tag ...

  3. WINDOWS-基础:WINDOWS常用API

    1.窗口信息 //MS 为我们提供了打开特定桌面和枚举桌面窗口的函数. hDesk=OpenDesktop(lpszDesktop,,FALSE,DESKTOP_ENUMERATE); //打开我们默 ...

  4. ZOJ-1360 || POJ-1328——Radar Installation

    ZOJ地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=360 POJ地址:http://poj.org/problem?id ...

  5. 【Codeforces #228】Solutions

    http://codeforces.com/contest/389 重新把号刷到Div 1 准备ACM?(我这么菜还是玩玩算了……) 官方题解出的很快 Div2 A: 怎么做都行……随便找俩数减就可以 ...

  6. MySQL查询当天数据以及大量查询时提升速度

    select * from 表名 where to_days(字段名) = to_days(now()) 一.数据库设计方面1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 ord ...

  7. JdbcTemplate类对sql的操作使用

    <!--方式一: dbcp 数据源配置,在测试环境使用单连接 --> <bean id="dataSource" class="org.apache.c ...

  8. 监控linux各主机系统时间是否一致

    #!/bin/bashSTATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3PASSWD='**************'print_h ...

  9. 【树论 倍增】51nod1709 复杂度分析

    倍增与位运算有很多共性:这题做法有一点像「线段树上二分」和「线段树套二分」的关系. 给出一棵n个点的树(以1号点为根),定义dep[i]为点i到根路径上点的个数.众所周知,树上最近公共祖先问题可以用倍 ...

  10. Ubuntu apt-get出现unable to locate package解决方案

    前言 刚安装好的ubuntu 17发现apt-get安装指令异常. 故经网上搜索调查发现,发现这个问题基本是因为apt-get需要更新的缘故. 解决方案 只需使用命令升级更新即可. sudo apt- ...