HDU 5228 ZCC loves straight flush 暴力
题目链接:
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 暴力的更多相关文章
- HDU 5228 ZCC loves straight flush( BestCoder Round #41)
题目链接:pid=5228">ZCC loves straight flush pid=5228">题面: pid=5228"> ZCC loves s ...
- hdu 5288 ZCC loves straight flush
传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K ...
- 暴力 BestCoder Round #41 1001 ZCC loves straight flush
题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...
- HDU 4876 ZCC loves cards(暴力剪枝)
HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...
- hdu 4876 ZCC loves cards(暴力)
题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...
- hdu 4873 ZCC Loves Intersection(大数+概率)
pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...
- HDU 4873 ZCC Loves Intersection(可能性)
HDU 4873 ZCC Loves Intersection pid=4873" target="_blank" style="">题目链接 ...
- hdu 4882 ZCC Loves Codefires(数学题+贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...
- HDU 4882 ZCC Loves Codefires (贪心)
ZCC Loves Codefires 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/B Description Though ...
随机推荐
- 记利用frp配合nginx实现内网透传
frp下载 背景 : 内网有一台服务器A 在NAT背后 无法被其他客户端访问 借助公网服务器B来配置内网透传 即可通过B来访问A 服务端安装frps 启动: ./frps -c frps.ini 配置 ...
- Java NIO (1)
Java NIO (1) 看了下java核心技术这本书 关于nio的部分介绍比较少,而且如果自己写服务器的话nio用的还是比较多,整理一下nio的资料 java中nio主要是三个组件 Buffers ...
- Anaconda快速加载opencv
刚刚发现了两种Anaconda快速加载opencv的方法,亲测有效: 第一种: 直接在Navigator Environment 中搜opencv 如果搜不到,登陆Anaconda Cloud官网 h ...
- PAT-A 1009. Product of Polynomials
参考:https://www.jianshu.com/p/e7a3ee0f82d9 #include<bits/stdc++.h> using namespace std; ; doubl ...
- leetcode-744-Find Smallest Letter Greater Than Target(改进的二分查找)
题目描述: Given a list of sorted characters letters containing only lowercase letters, and given a targe ...
- 多级反馈序列c语言模拟实现
多级反馈队列调度算法: 1.设置多个就绪队列,并给队列赋予不同的优先级数,第一个最高,依次递减. 2.赋予各个队列中进程执行时间片的大小,优先级越高的队列,时间片越小. 3.当一个新进程进入内存后,首 ...
- 什么是thinkphp
ThinkPHP是一个快速.简单的基于MVC和面向对象的轻量级PHP开发框架,遵循Apache2开源协议发布,从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,尤其注重开发体验 ...
- js获取上月的最后一天
一.问题: 在最近的开发中遇到一个需求,需要初始化默认时间为上月的最后一天 而在日历中这个值在每个月都不是固定的 二.分析: 问题可以转化为,获取指定月份时间的月末最后一天,下边是代码,供大家参考 f ...
- Flask开发环境搭建
基础准备 Python 3.6.5 Conda Visual Studio Code 虚拟环境 创建虚拟环境 conda create -n flask 激活虚拟环境 activate flask 关 ...
- shell 参数
转:http://hi.baidu.com/ipvsadm/item/489d9e16460195ddbe9042ee linux中shell变量$#,$@,$0,$1,$2的含义解释 linux中s ...