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 ...
随机推荐
- 如何使用gitbash 把你的代码托管到github
1.如果你没有创建仓库 mkdir vuex-playList cd vuex-playList git init touch README.md git add README.md git comm ...
- 简述对Vuex的理解
1.什么是Vuex: Vuex是一个专为Vue.js应用程序开发的状态管理模式. 2.使用Vuex的原因: 当我们遇到多个组件共享状 ...
- redis应用场景:实现简单计数器-防止刷单
redis应用场景:实现计数器-防止刷单 最近由于双11要来临,公司需要在接口请求上,做一下并发限制的处理,或者做一个防止刷单的安全拦截:比如:一个接口请求,限制每秒请求总数为200次,超过200次就 ...
- HBase操作一
package Hbase; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.a ...
- Google protobuf使用技巧和经验
Google protobuf是非常出色的开源工具,在项目中可以用它来作为服务间数据交互的接口,例如rpc服务.数据文件传输等.protobuf为proto文件中定义的对象提供了标准的序列化和反序列化 ...
- linux——Shell编程基础
1. shell 脚本的执行方式 1.1 直接绝对路径执行 1.2 相对路径执行 首先进入到shell脚本所造的目录 PS:用./执行要增加x权限.用bash执行可以不增加x权限 1.3 在当前she ...
- 程序与程序之间共享对象:MarshalByRefObject
源自于:http://stackoverflow.com/questions/439173/message-pumps-and-appdomains/442316 程序与程序之间共享对象: Marsh ...
- lamp环境搭建(centos6.9+apache2.4+mysql5.7+php7.1)
lamp环境搭建(centos6.9+apache2.4+mysql5.7+php7.1) 安装前准备:CentOS 6.9 64位 最小化安装 yum install -y make gcc gcc ...
- 无旋treap的区间操作实现
最近真的不爽...一道维修数列就做了我1上午+下午1h+1晚上+晚上1h+上午2h... 一道不错的自虐题... 由于这一片主要讲思想,代码我放这里了 不会无旋treap的童鞋可以进这里 呵呵... ...
- mysql 创建外键时发生错误的原因和解决方法
可以去网上查看错误号,就能知道到底哪里出错了 https://zhidao.baidu.com/question/359868536.html 这里1452对应的错误是因为建立外键的表中还有数据,所以 ...