暴力 BestCoder Round #41 1001 ZCC loves straight flush

 

题目传送门

 1 /*  2  m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换  3  ╰·  4 */  5 #include <cstdio>  6 #include <algorithm>  7 #include <iostream>  8 #include <cstring>  9 #include <string> 10 using namespace std; 11 12 const int MAXN = 1e4 + 10; 13 const int INF = 0x3f3f3f3f; 14 15 int main(void) //BestCoder Round #41 1001 ZCC loves straight flush 16 { 17 //freopen ("A.in", "r", stdin); 18 19 int t; 20 scanf ("%d", &t); 21 while (t--) 22  { 23 int c[5], d[5], m[5][20]; 24 memset (m, 0, sizeof (m)); 25 string s; 26 for (int i=0; i<5; ++i) 27  { 28 cin >> s; c[i] = s[0] - 'A'; 29 if (s.size () == 2) d[i] = s[1] - '0'; 30 else d[i] = 10 + s[2] - '0'; 31 m[c[i]][d[i]]++; 32  } 33 34 int mn = INF; 35 for (int i=0; i<5; ++i) 36  { 37 int d = c[i]; 38 for (int j=1; j<=10; ++j) 39  { 40 int cnt = 0; 41 for (int k=j; k<j+5; ++k) 42  { 43 int x = k; 44 if (x == 14) x = 1; 45 if (m[d][x] == 1) cnt++; 46  } 47 mn = min (mn, 5 - cnt); 48  } 49  } 50 51 printf ("%d\n", mn); 52  } 53 54 return 0; 55 }

 

你可能感兴趣的:(round)