博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5288 ZCC loves straight flush
阅读量:6824 次
发布时间:2019-06-26

本文共 2514 字,大约阅读时间需要 8 分钟。

 

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

 

转载于:https://www.cnblogs.com/njczy2010/p/5246600.html

你可能感兴趣的文章
leetcode 55.跳跃游戏
查看>>
flexPaper +swftools实现文档在线阅读
查看>>
分形树的绘制
查看>>
loadrunner请求中有汉字 如何编码
查看>>
java数据结构 • 面向对象 • 异常 • 随机数·时间
查看>>
springmvc 实现pc端手机端适配(同一个请求根据不同客户端展示不同界面)
查看>>
BTree和B+Tree详解
查看>>
VS2005工程迁移到Eclipse CDT
查看>>
Linux高端内存映射(上)【转】
查看>>
usb_control_msg参数详解【转】
查看>>
8086汇编指令速查手册
查看>>
j2EE web.xml中的url-pattern的映射规则
查看>>
带输入输出参数的存储过程
查看>>
字符编码简介
查看>>
LevelDB源码之六缓存机制
查看>>
双向链表
查看>>
安装unity3d多个版本共存
查看>>
如何获取模拟器安装的app的位置
查看>>
[LeetCode] Largest Rectangle in Histogram 解题报告
查看>>
未能加载文件或程序集Newtonsoft.Json, Version=4.5.0.0
查看>>