暴力 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 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4509574.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值