hdu5228 ZCC loves straight flush(模拟)
来源:互联网 发布:钓鱼软件app 编辑:程序博客网 时间:2024/05/21 10:06
ZCC loves straight flush
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 611 Accepted Submission(s): 266
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.
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',
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.
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
3A1 A2 A3 A4 A5A1 A2 A3 A4 C5A9 A10 C11 C12 C13
Sample Output
012
Source
BestCoder Round #41
Recommend
hujie | We have carefully selected several similar problems for you: 5231 5230 5229 5227 5226
解析:模拟。直接暴力枚举所有的胜利情况,然后一一匹配,得到匹配牌数x,需要改变的牌就为5-x。
需要注意的是,5招牌并不一定是有序的,也就是说:A1 A2 A5 A4 A3 也是同花顺。一开始没注意到这个,调试一下午都没找出来。
代码:
#include<cstdio>#include<cstring>#include<algorithm>#define maxn 10using namespace std;int a[maxn],b[maxn];char s[maxn];void work(){ int i,j,k,p,q,sum,ans,x,y; for(i=1;i<=5;i++) { scanf("%s",s); a[i]=s[0]-'A'; b[i]=s[1]-'0'; k=strlen(s); for(j=2;j<k;j++)b[i]=b[i]*10+s[j]-'0'; } ans=5; for(i=0;i<4;i++) for(j=1;j<=10;j++) { sum=0,x=i,y=j; for(k=0;k<5;k++) { if(y==14)y=1; for(p=1;p<=5;p++) if(a[p]==x && b[p]==y)sum++; y++; } ans=min(ans,5-sum); } printf("%d\n",ans); }int main(){ freopen("1.in","r",stdin); int t,i,j,k; while(scanf("%d",&t)!=EOF) for(i=1;i<=t;i++)work(); return 0; }
0 0
- hdu5228 ZCC loves straight flush(模拟)
- HDU5228 ZCC loves straight flush
- ZCC loves straight flush
- HD5228 ZCC loves straight flush
- H - ZCC loves straight flush
- hdu 5528 ZCC loves straight flush (暴力模拟)
- HDU 5228 ZCC loves straight flush
- hdu 5228 ZCC loves straight flush
- hdu 5228 ZCC loves straight flush
- HDU 5228 ZCC loves straight flush
- HDU 5228 ZCC loves straight flush
- HDU 5228 ZCC loves straight flush
- HDU 5228-ZCC loves straight flush
- hdu 5228 ZCC loves straight flush && BestCoder Round #41 1001
- HDU 5228 ZCC loves straight flush( BestCoder Round #41)
- hdu 5228 暴力枚举ZCC loves straight flush
- ZCC loves straight flush HDU - 5228(暴力)
- [HDOJ 4879] ZCC loves march [模拟+数据结构]
- 18.自定义键盘 toolbar的barTintColor UIBarButtonItem的使用 datePick使用
- C 语言状态机编程-去掉代码注释
- xUtils 中的BitmapUtils 全面注释
- sql 的性能优化
- xUtils 中的BitmapUtils 全面注释
- hdu5228 ZCC loves straight flush(模拟)
- 关于派生类构造函数与基类构造函数的调用顺序问题
- web前端框架
- linux最简单的驱动编写及测试流程
- C语言中的UNION
- C/C++数组学习(一)
- Java中的引用类型和垃圾回收
- [SSH_easyUI]细节4:后台主要代码
- android touch事件分发机制