poj 1013(uva 608) Counterfeit Dollar
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std; #define FOR(i,s,t) for (int i = s; i < t; ++i)
#define MEM(s,v) memset(s, v, sizeof(s)) #define EPS 1e-8
#define _N 15
#define _M 105
#define PI acos(-1.0) int even[], light[], heavy[];
char l[_N], r[_N], b[_N]; void set_union(int *a, char *b)
{
FOR (i, , strlen(b)) { a[b[i] - 'A'] += ; }
} int main()
{
int n; scanf("%d", &n); while (n--) {
MEM (even, ); MEM (light, ); MEM (heavy, );
FOR (i, , ) {
scanf("%s%s%s", l, r, b);
if (b[] == 'e') {
set_union(even, l);
set_union(even, r);
} else if (b[] == 'u') {
set_union(heavy, l);
set_union(light, r);
} else {
set_union(light, l);
set_union(heavy, r);
}
}
int _l[], _h[];
FOR (i, , ) {
_l[i] = light[i] * (!even[i] && light[i]);
_h[i] = heavy[i] * (!even[i] && heavy[i]);
}
int max_c = , max_n = , _t = ;
FOR (i, , ) if (_l[i] > max_n) {
max_c = i; max_n = _l[i]; _t = -;
}
FOR (i, , ) if (_h[i] > max_n) {
max_c = i; max_n = _h[i]; _t = ;
}
printf("%c is the counterfeit coin and it is %s.\n", max_c + 'A', _t == - ? "light" : "heavy");
}
return ;
}
poj 1013(uva 608) Counterfeit Dollar的更多相关文章
- Poj 1013 Counterfeit Dollar / OpenJudge 1013(2692) 假币问题
1.链接地址: http://poj.org/problem?id=1013 http://bailian.openjudge.cn/practice/2692 http://bailian.open ...
- POJ 1013 Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36206 Accepted: 11 ...
- POJ 1013:Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42028 Accepted: 13 ...
- Counterfeit Dollar 分类: POJ 2015-06-12 15:28 19人阅读 评论(0) 收藏
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41559 Accepted: 13 ...
- POJ1013 Counterfeit Dollar
题目来源:http://poj.org/problem?id=1013 题目大意:有12枚硬币,其中有一枚假币.所有钱币的外表都一样,所有真币的重量都一样,假币的重量与真币不同,但我们不知道假币的重量 ...
- Counterfeit Dollar -----判断12枚钱币中的一个假币
Counterfeit Dollar Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u ...
- poj1013.Counterfeit Dollar(枚举)
Counterfeit Dollar Time Limit: 1 Sec Memory Limit: 64 MB Submit: 415 Solved: 237 Description Sally ...
- POJ 1013 小水题 暴力模拟
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35774 Accepted: 11 ...
- POJ 3525/UVA 1396 Most Distant Point from the Sea(二分+半平面交)
Description The main land of Japan called Honshu is an island surrounded by the sea. In such an isla ...
随机推荐
- DWR Annotations
DWR Annotations DWR 标注是用来代替 dwr.xml 或者与其一同工作的. 1.初始配置 <servlet> <description>DWR contr ...
- C++多线程二
SuspendThread()暂停一个线程,ResumeThread()重启一个线程.参数均为线程的句柄. #include <iostream> #include <windows ...
- JSON对象和字符串转换
- java正则表达式获取指定HTML标签的指定属性值
package com.mmq.regex; import java.util.ArrayList; import java.util.List; import java.util.regex.Mat ...
- NAVICAT 拒绝链接的问题
处理步骤 1.先在原有的建一个新的用户 2.成功后,再点击原有的,即可使用
- BNU 51002 BQG's Complexity Analysis
模拟 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #incl ...
- Zabbix的安装及简单配置
Mysql源码安装:Mysql安装脚本 PHP源码安装:基于LNMP的Zabbbix之PHP源码安装 Nginx源码安装:Nginx安装 Zabbix监控端源码安装(包含Server和Agent):l ...
- VS2012配置Cocos2d-x的问题
cocos2d-x老是配置不成功,解决方案参考:http://blog.csdn.net/yangjingui/article/details/9408007 完整配置流程: 1 下载,最好通过SVN ...
- nginx 防 webshell 跨目录
对于在一台服务器上有多个虚拟主机的人来说,Apache有一个很好用的地方---配置php_admin_value,在里面配置一下 open_basedir就可以了. 但是Nginx却没有这样的设置 ...
- Big Data架构师技能图谱
大数据通用处理平台 Spark Flink Hadoop 分布式存储 HDFS 资源调度 Yarn Mesos 机器学习工具 Mahout Spark Mlib TensorFlow (Google ...