HD5228 ZCC loves straight flush
来源:互联网 发布:虚拟网络传销中的三虚 编辑:程序博客网 时间:2024/04/30 14:51
ZCC loves straight flush
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 541 Accepted Submission(s): 233
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
就是对ABCD四个分别寻找,数据少枚举一下就可以了。第一次做这个题居然还纠结这么久
#include <iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int t; scanf("%d",&t); getchar(); while(t--) { char card; int a[15],b[15],c[15],d[15]; int n; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); memset(d,0,sizeof(d)); for(int i=1;i<=5;i++) { // cin>>card>>n; scanf("%c%d",&card,&n); if(card=='A') a[i]=n; if(card=='B') b[i]=n; if(card=='C') c[i]=n; if(card=='D') d[i]=n; getchar(); } //for(int i=1;i<10;i++) // cout<<a[i]<<" "; int maxn=0; for(int i=1;i<=5;i++) { int count1=0,count2=0; if(a[i]>=1&&a[i]<10) { for(int j=1;j<=5;j++) { if(a[j]-a[i]>=1&&a[j]-a[i]<=4&&a[j]) count1++; } } if(a[i]>=10) { for(int j=1;j<=5;j++) { if((a[j]-a[i]>=1&&a[j]-a[i]<=4)||a[j]==1) count1++; } } maxn=max(maxn,count1); } for(int i=1;i<=5;i++) { int count1=0; if(b[i]>=1&&b[i]<10) { for(int j=1;j<=5;j++) { if(b[j]-b[i]>=1&&b[j]-b[i]<=4) count1++; } } if(b[i]>=10) { for(int j=1;j<=5;j++) { if((b[j]-b[i]>=1&&b[j]-b[i]<=4)||b[j]==1) count1++; } } maxn=max(maxn,count1); } for(int i=1;i<=5;i++) { int count1=0; if(c[i]>=1&&c[i]<10) { for(int j=1;j<=5;j++) { if(c[j]-c[i]>=1&&c[j]-c[i]<=4) count1++; } } if(c[i]>=10) { for(int j=1;j<=5;j++) { if((c[j]-c[i]>=1&&c[j]-c[i]<=4)||c[j]==1) count1++; } } maxn=max(maxn,count1); } for(int i=1;i<=5;i++) { int count1=0; if(d[i]>=1&&d[i]<10) { for(int j=1;j<=5;j++) { if(d[j]-d[i]>=1&&d[j]-d[i]<=4) count1++; } } if(d[i]>=10) { for(int j=1;j<=5;j++) { if((d[j]-d[i]>=1&&d[j]-d[i]<=4)||d[j]==1) count1++; } } maxn=max(maxn,count1); } printf("%d\n",4-maxn); } return 0;}
0 0
- HD5228 ZCC loves straight flush
- ZCC loves straight flush
- HDU5228 ZCC loves straight flush
- H - ZCC loves straight flush
- HDU 5228 ZCC loves straight flush
- hdu 5228 ZCC loves straight flush
- hdu 5228 ZCC loves straight flush
- hdu5228 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(暴力)
- hdu 5528 ZCC loves straight flush (暴力模拟)
- HDU4882-ZCC Loves Codefires
- 【随堂笔记】变量与赋值
- dcm4che2-Java Library for DICOM
- 《算法导论》8、快速排序实现(C++)
- 第三层---面向对象原则
- 使用 unixtime 时间转换成正常时间,取得每天最高的数据
- HD5228 ZCC loves straight flush
- MAVEN 生命周期与插件笔记
- 英文
- 第一题
- 深入分析Java ClassLoader原理
- C++ sizeof不完全总结
- React入门指南
- python学习笔记
- Struct和Class的区别