HDU 5228 ZCC loves straight flush
来源:互联网 发布:mac队全灭 编辑:程序博客网 时间:2024/05/18 01:37
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直接暴力上
#include<iostream>#include<cmath>#include<map>#include<vector>#include<queue>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 100005;int T, n, m, ans, t[4][15];char s[5];int main(){ while (scanf("%d", &T) != EOF) { memset(t, 0, sizeof(t)); for (int i = 0; i < 5; i++) { scanf("%s", s); int k = s[1] - '0'; if (s[2]) k = k * 10 + s[2] - '0'; t[s[0] - 'A'][k] = 1; } ans = 4; for (int i = 0; i < 4; i++) for (int j = 1; j <= 10; j++) { int p = 0; for (int k = 0; k <= 4; k++) if (t[i][(j + k - 1) % 13 + 1]) { p++; ans = min(ans, 5 - p); } } printf("%d\n", ans); }}
0 0
- 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
- 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(暴力)
- HD5228 ZCC loves straight flush
- HDU5228 ZCC loves straight flush
- H - ZCC loves straight flush
- hdu 5528 ZCC loves straight flush (暴力模拟)
- hdu5228 ZCC loves straight flush(模拟)
- hdu 4882 ZCC Loves Codefires
- JAVA设计模式(19):行为型-观察者模式(Observer)
- Spring依赖注入的四种方式
- Android自定义View
- 得到教务处成绩脚本beta5
- SQLite内存表的一些操作
- HDU 5228 ZCC loves straight flush
- Spark1.3.1集群安装
- Flash3.0 下拉菜单制作
- 第三章第42题
- Altium Designer 电路仿真
- C++之STL中set的用法总结
- Linux 软件看门狗 watchdog
- 安卓学习记录
- (推荐)Android 编程下的 TraceView 简介及其案例实战