题目链接:

hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5228

bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=582&pid=1001

题解:

首先可以先考虑花色,把输入按照花色分组,对于每种花色同花顺的情况只有十种:(1,2,3,4,5)~(10,11,12,13,1),然后对每种花色的每种同花顺都对照一下,看看当前的牌有几张不在里面,这几张牌就是我们要替换的了,全部的情况都跑一遍取最小值。

代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=;
const int INF=0x3f3f3f3f; //mat[i]表示第i种同花顺的状态
int mat[maxn][maxn]; //输入按花色分组
vector<int> arr[maxn]; void get_mat(){
memset(mat,,sizeof(mat));
for(int i=;i<;i++){
for(int j=;j<;j++){
mat[i][(i+j)%+]=true;
}
}
} //暴力枚举
void solve(int cur,int *ma,int &ans){
int cnt=;
for(int i=;i<arr[cur].size();i++){
int x=arr[cur][i];
if(ma[x]) cnt++;
}
ans=min(ans,-cnt);
} void init(){
for(int i=;i<maxn;i++) arr[i].clear();
} int main(){
get_mat();
int tc;
scanf("%d",&tc);
while(tc--){
init();
char ch[];
for(int i=;i<;i++){
scanf("%s",ch);
if(ch[]!='\0'){
int tmp=(ch[]-'')*+ch[]-'';
arr[ch[]-'A'].push_back(tmp);
}
else arr[ch[]-'A'].push_back(ch[]-'');
}
int ans=INF;
for(int i=;i<;i++){
for(int j=;j<;j++){
solve(i,mat[j],ans);
}
}
printf("%d\n",ans);
}
return ;
}

HDU 5228 ZCC loves straight flush 暴力的更多相关文章

  1. HDU 5228 ZCC loves straight flush( BestCoder Round #41)

    题目链接:pid=5228">ZCC loves straight flush pid=5228">题面: pid=5228"> ZCC loves s ...

  2. hdu 5288 ZCC loves straight flush

    传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K ...

  3. 暴力 BestCoder Round #41 1001 ZCC loves straight flush

    题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...

  4. HDU 4876 ZCC loves cards(暴力剪枝)

    HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...

  5. hdu 4876 ZCC loves cards(暴力)

    题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...

  6. hdu 4873 ZCC Loves Intersection(大数+概率)

    pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...

  7. HDU 4873 ZCC Loves Intersection(可能性)

    HDU 4873 ZCC Loves Intersection pid=4873" target="_blank" style="">题目链接 ...

  8. hdu 4882 ZCC Loves Codefires(数学题+贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...

  9. HDU 4882 ZCC Loves Codefires (贪心)

    ZCC Loves Codefires 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/B Description Though ...

随机推荐

  1. 浅淡 RxJS WebSocket

    const open$ = new Subject(); const ws = webSocket({ url: 'wss://echo.websocket.org', openObserver: o ...

  2. HAProxy负载均衡策略

    HAProxy是一个使用C语言编写的自由及开放源代码软件,其提供高可用性.负载均衡,以及基于TCP和HTTP的应用程序代理.HAProxy是支持虚拟主机的,HAProxy的优点能够补充Nginx的一些 ...

  3. c++读取ini的Section节名

    // ConsoleApplication1.cpp : 定义控制台应用程序的入口点.// #include "stdafx.h"#include "iostream&q ...

  4. jquery.ajax的方法使用

    $.ajax({ type: 'post', url:"{:U('Admin/Shop')}", data:{id:id}, dataType: "json", ...

  5. STM32(6)——USART串口的使用

    1. 串口的基本概念 在STM32的参考手册中,串口被描述成通用同步异步收发器(USART),它提供了一种灵活的方法与使用工业标准NRZ异步串行数据格式的外部设备之间进行全双工数据交换.USART利用 ...

  6. MySQL存取特殊数据类型

    一.存取大文本数据 数据库设计: DDL: CREATE TABLE `article` ( `id` ) COLLATE utf8_bin NOT NULL COMMENT '编号', `conte ...

  7. 【commons】邮件发送工具——commons-email

    一.概述 直接通过官网的overview进行了解,一句话概括如下: Commons Email aims to provide a API for sending email. It is built ...

  8. 20155209 2016-2017-2 《Java程序设计》第二周学习总结

    20155209 2016-2017-2 <Java程序设计>第二周学习总结 教材学习内容总结 类型总结:常用定义byte(符号%d):short(符号%d):int(符号%d):long ...

  9. PANIC: HOME is defined but could not find Nexus_4_API_22.ini file in $HOME/.android/avd (Note: avd is searched in the order of $ANDROID_AVD_HOME,$ANDROID_SDK_HOME/.android/avd and $HOME/.android/avd)

    sudo cp /root/.android/avd/*.ini  $Home/.android/avd/ sudo cp -r  /root/.android/avd/*.avd  $Home/.a ...

  10. Potree学习总结

    一.      简介 基于Web端的三维模型展示,这里仅介绍Three.js和Potree. Three.js 是一款基于WebGL的运行在浏览器中的 3D 开源引擎,用它创建各种三维场景.它类似于M ...